I
I
Ivan2019-03-10 22:48:30
PostgreSQL
Ivan, 2019-03-10 22:48:30

How to search by json cell in an array?

There is a task to select all rows where the json string has an array and in the array - an element that satisfies the condition, i.e.
{"a" : [2,3,4,5]}, I need to return all rows where in row a the array has an element with value 3, for example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-03-10
@vhuk1802

SELECT *
FROM table_name
WHERE (column_name->'a')::jsonb @> '3'::jsonb

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question