Re: How to select values in a JSON type of column?
От
Thomas Kellerer
Тема
Re: How to select values in a JSON type of column?
Дата
Msg-id
35c562d1-5324-6f10-f2a4-624da3acbbd2@gmx.net
Ответ на
How to select values in a JSON type of column? (Snjezana Frketic)
Список
Дерево обсуждения
How to select values in a JSON type of column? Snjezana Frketic <frketic.snjezana@gmail.com>
Re: How to select values in a JSON type of column? Thomas Kellerer <shammat@gmx.net>
Re: How to select values in a JSON type of column? Snjezana Frketic <frketic.snjezana@gmail.com>
Re: How to select values in a JSON type of column? Snjezana Frketic <frketic.snjezana@gmail.com>
Re: How to select values in a JSON type of column? "David G. Johnston" <david.g.johnston@gmail.com>
Re: How to select values in a JSON type of column? Snjezana Frketic <frketic.snjezana@gmail.com>
Re: How to select values in a JSON type of column? Thomas Kellerer <shammat@gmx.net>
Re: How to select values in a JSON type of column? "David G. Johnston" <david.g.johnston@gmail.com>
Re: How to select values in a JSON type of column? Snjezana Frketic <frketic.snjezana@gmail.com>
Snjezana Frketic schrieb am 18.11.2020 um 11:29:
> I have a column called |targeting| in a table called |campaigns| .
> [...]
> and I need to select all the |ids| in |includes|.
> Currently, I am doing it like this
>
> SELECT |targeting#>'{targets,0,audienceSegments,0,includes,0,segments,allOf,0,ids}'FROM campaigns;|
>
If you are on Postgres 12 or later, this can be done using jsonb_path_query_array:
select jsonb_path_query_array(targeting, '$.targets[*].*.includes.**.ids.id')
from campaigns
Online example: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=ee7f6e73055ffb3a98fcfd3d86763e35
Thomas
В списке pgsql-general по дате отправления