Check for overlaps for several arrays in one query I have such table

create table tbl (
    id serial primary key,
    arr text[]
);


With such data

INSERT INTO tbl(arr) VALUES ('{dog, mouse}'), ('{fish, cat, rat}');


If my input is a single array - {dog} - everything is simple:

select id from tbl where arr &amp;&amp; '{dog}'

| Id | 
|----| 
| 1  | 


But what I need is the ability to pass several arrays as an input. For example with input {cat}, {dog} I expect output to be:

| Id | 
|----| 
| 2  | 
| 1  | 


And even more how can I with input {cat}, {bird}, {dog} receive:

| Id   | 
|------| 
| 2    | 
| null | 
| 1    | 


Looping through the input array and make a query for each its item is not an option, I want to fire as few requests as possible

Here's the corresponding sqlfiddle - http://sqlfiddle.com/#!15/5740d/2
I suppose you want something like this:

with param (p) as 
  ( values ('{cat}'), 
           ('{bird}'), 
           ('{dog}')
  ) 
select * 
from param left join tbl 
     on param.p::text[] &amp;&amp; tbl.arr ;


Result:

   p    | id |      arr       
--------+----+----------------
 {cat}  |  2 | {fish,cat,rat}
 {bird} |    | 
 {dog}  |  1 | {dog,mouse}
(3 rows)