Du kan bruge arrays og overlapningsoperatoren &&
, f.eks.:
with my_table(name1, name2) as (
values ('Emily', 'Bob'), ('Ben', 'Jack'), ('Bob', 'Ben')
)
select *
from my_table
where array[name1, name2] && array['Emily', 'Jack', 'James', 'Chloe'];
name1 | name2
-------+-------
Emily | Bob
Ben | Jack
(2 rows)