Re: jsonb and where clause?
| От | Ivan E. Panchenko |
|---|---|
| Тема | Re: jsonb and where clause? |
| Дата | |
| Msg-id | b9341406-f066-ea08-5c0d-1a7404a95df3@postgrespro.ru обсуждение исходный текст |
| Ответ на | jsonb and where clause? (Bjorn T Johansen <btj@havleik.no>) |
| Ответы |
Re: jsonb and where clause?
|
| Список | pgsql-general |
Hi Bjorn,
28.11.2017 11:18, Bjorn T Johansen пишет:
> Hi.
>
> Just starting to look at how to use jsonb columns and I have a question. I have found out that I can use the
followingto search for a value inside
> the jsonb column:
>
> select * from orders where info ->> 'customer' = 'John Doe' (where info is the jsonb column)
>
>
> But what if the jsonb column contains an json array, how can I search then?
>
> info -> [ { "customer" : "John Doe" } ]
If you know the index in array, you can search like
info->0->>'customer'
If you want to search in any array element, you need to use JSQUERY
extension,
see https://github.com/postgrespro/jsquery
>
>
> btw, using PostgreSQL 9.6 but will be moving to 10 soon.
>
>
> Regards,
>
> BTJ
>
Regards,
Ivan
В списке pgsql-general по дате отправления: