Skip to content
Advertisement

How to query Json array in jsonb in Postgresql

I have a jsonb column which have following rows

ROW1:

ROW 2:

ROW 3:

I want to find the rows which contain sgi:irix in the key cpe23Uri

Which query should i use for best performance?

Advertisement

Answer

You could use an exists condition with a correlated subquery that uses jsonb_array_element() to unnest and search the array:

Demo on DB Fiddle

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement