Search Postgresql Archives

Re: json select question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux