有个奇怪的问题。。。
select * from a where a.id in(select id from b);
select * from a where exists(select id from b);
为何这两个语句查出的结果不同??in 和exists结果有区别?
------解决方案--------------------select * from a where a.id in(select id from b);
相当于
select * from a where exists(select id from b wherea.id=b.id);
------解决方案--------------------select * from a where exists(select id from b where a.id=b.id);
--B表有id=a.id的数据才返回TRUE
和
select * from a where exists(select id from b);
--只要B表有数据就返回TRUE