4

I am looking to perform a query that returns a row if the array column type contains at least one entry from another array, so example:

Row1

col_a = {1,2}

I want to a query that says col_a contains {3,1} and it should return Row1 because col_a contains '1'.

The value {3,1} in the example will come from another subquery. I am not sure this is possible, and I am struggling to find an example. The closest I found was the @> operator but that requires all entries to be in col_a right rather than any matching?

1 Answer 1

9

You can use the && (overlap) operator

select array[1,2,3,4] && array[3,9];
 ?column?
----------
 t
(1 row)
Sign up to request clarification or add additional context in comments.

1 Comment

Fantastic I missed this operator thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.