2

In Postgres, I need to select all rows where any value in an array (passed as variable) is equal to any value in the column (that is also an array). This means something like this:

SELECT * 
from table 
where ANY (value_in_an_array_variable) = ANY (value_in_a_column_array);

If there is no direct way what's the best alternative?

1 Answer 1

4

You are looking for the overlaps ("have elements in common") operator:

select *
from some_table
where array_column && array[1,2,3];
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.