1、用法
in : select * from A where id in (select id from B);
exists : select * from A where exists(select 1 from B where B.id=A.id);
2、
select … from table where exists (subquery)
语法可以理解为:
将主查询的数据,放到子查询中做条件验证,根据验证结果(TRUE 或 FALSE)来决定主查询的数据结果是否得以保留
exists(subquery)只会返回true或者false,子查询中select* 亦可以是select 1 或select ‘x’,因为实际执行的时候回忽略select清单!