<分区>
IN
子句的作用类似于 OR
,
select from table where id in (1, 2, 3)
即 如果组中的任何项目匹配则选择(如果 id 为 1、2 或 3 则返回)。
我需要类似的东西,但基于两列,只有当 ColumnA
具有 ColumnB
的所有值时它才应该返回。
例如,
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
等等。我知道 in every of
不是一个合适的关键字,我只是想展示一个例子。
我无法尝试任何事情,因为我无法理解这个逻辑。