add tag
Anonymous 1800
I have a question about this fiddle:

<>https://dbfiddle.uk?rdbms=postgres_10&fiddle=18e882041937dbc7b04312f97e1ed0e6

I have an input of type array that can contain any color eg. '{"Black", "Pink", "ETC"}'.
I can return a record where a specific color is in the array but I'd rather not loop through the input colors to return all rows one by one.

I would like to return all rows where a color in the input array of any length is inside data (text[]) column. Is this possible?

Example:

Input: '{"Black", "Pink", "ETC"}'
Output: return row with id = 2

Input: '{"Brown", "Pink", "ETC"}'
Output: returns no rows

Input: '{"Black", "Red", "White"}'
Output: return rows with id = 1 and 2

Top Answer
Truilus
Sounds like you are looking for the overlaps operator ("have elements in common"):

```
select *
from test_table
where data && array['Black', 'Red', 'White']
```


Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.