一般在不含null值的列中进行处理时,二者功能可以等效。
exists使用相关子查询,in使用非相关子查询。
比如select a.* from ta a where not exists(select 1 from tb where id=a.id)
select a.* from ta a where id not in(select id from tb)
select a.* from ta a left join tb b on a.id=b.id where b.id is null
exists使用相关子查询,in使用非相关子查询。
比如select a.* from ta a where not exists(select 1 from tb where id=a.id)
select a.* from ta a where id not in(select id from tb)
select a.* from ta a left join tb b on a.id=b.id where b.id is null
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货