Query for element of array in JSON column

后端 未结 4 1322
忘了有多久
忘了有多久 2020-11-27 16:32

Recently upgraded to using PostgreSQL 9.3.1 to leverage the JSONfunctionalities. In my table I have a json type column that has a structure like this:

{
   \         


        
4条回答
  •  醉话见心
    2020-11-27 17:04

    Came across this post and found that you can directly query on table like this:

    SELECT *
    FROM   table_name, json_array_elements(json_column) AS data
    WHERE  data->>'id' = 123;
    

    Omitting this part:

    json_array_elements(t.json_col->'emails')
    

提交回复
热议问题