jsonb and where clause?

From: Bjorn T Johansen <btj(at)havleik(dot)no>
To: pgsql-general(at)postgresql(dot)org
Subject: jsonb and where clause?
Date: 2017-11-28 08:18:07
Message-ID: 20171128091807.218d7809@pennywise-btj
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 following to 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" } ]

btw, using PostgreSQL 9.6 but will be moving to 10 soon.

Regards,

BTJ

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ivan E. Panchenko 2017-11-28 08:28:55 Re: jsonb and where clause?
Previous Message Dilip Kumar 2017-11-28 07:32:56 Re: ERROR: too many dynamic shared memory segments