From: | John R Pierce <pierce(at)hogranch(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: json select question |
Date: | 2016-09-22 00:41:04 |
Message-ID: | 3f9679b6-1a6b-b9b2-d387-cb6b31c3d604@hogranch.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 9/21/2016 4:54 PM, CS DBA wrote:
> How can i pull a unique list of all json column names? such as book_name, catalog_name, etc
try json_object_keys() ...
https://www.postgresql.org/docs/current/static/functions-json.html
but this will only pull the top level keys, like (from the first row of
your example) , book_name, author... it won't pull out any second level
fields like first_name, last_name.
you'll likely need to run this on all rows, and do a group by to get
what you need.
thats a pretty messy way of storing data, btw, and not very relational,
having a key name indicate a record type, and tossing all the record
types into the same table.
--
john r pierce, recycling bits in santa cruz
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-09-22 01:29:43 | Re: Unstable C Function |
Previous Message | Patrick B | 2016-09-21 23:57:10 | Re: overwrite column data select - Postgres 9.2 |