I have a table where one of the columns is a JSON array. for each key there are multiple values.
So I use this query to select out the JSON
select x.cola eventid, x.colb
from special_event_conflicts t
cross join lateral json_each(t.eventid) as x(cola, colb)
which produces
"525947";"{"f1":133,"f2":2428,"f3":"MULTILINESTRING((1013339.30779158 180228.160778359,1013395.51179424 180119.844273224))"}"
what I want is to be able to select out the f1,f2,f3 values into there own columns
The most simple way is using the ->>
operator:
SELECT
x.event_id,
x.colb ->> 'f1' as f1,
x.colb ->> 'f2' as f2,
x.colb ->> 'f3' as f3
FROM <YOUR QUERY>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.