IN
clause works like OR
,
select from table where id in (1, 2, 3)
ie selects in case any of the item in group matches (returns if id is 1, 2 or 3).
I need something similar, but based on two columns, and it should return only if ColumnA
has all the values of ColumnB
.
For eg,
ColumnA ColumnB
---------------------------
1 a
2 b
3 c
1 a
1 b
1 c
select CoumnA from table where CoumnA in every ColumnB of (a, b, c);
-> 1 --since only 1 has all a, b and c
select CoumnA from table where CoumnA in every ColumnB of (b);
-> 1 --since 1 has b
-> 2 --since 2 has b
And so on. I know in every of
is not a proper keyword, I'm just trying to show an example.
I couldn't try anything since I couldn't get my head around this logic.