var result = {};
- и всё будет нормально. SELECT *
FROM table
WHERE (SELECT array_agg((t->>'category_id')::INT) FROM jsonb_array_elements(data->'items') AS t) && ARRAY[1,3,5]
SELECT *
FROM table
WHERE ARRAY(SELECT t.category_id FROM jsonb_to_recordset(data->'items') AS t(category_id INT)) && ARRAY[1,3,5]