0

I want to do something like this

SELECT t.*
FROM table t
WHERE json_array_elements(t.data->'other_field'->my_array) && ARRAY['some_values']

But I can't, due to this error ERROR: set-returning functions are not allowed in WHERE I searched a lot for a solution without using other joins or stuff like that. So how can I do something like this in query as less complex as it can be?

1 Answer 1

1

If the array elements are strings, you can use the ?| operator. But that only works with jsonb values. As your column seems to be a json you need to cast it:

select *
from the_table t
where (t.data::jsonb -> 'other_field' -> 'my_array') ?| array['..', '..'];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.