in和exists的区别 in和exists的区别 in和exists的区别 in适合A表比B表大的情况,in会做全表扫描,最坏情况下要扫描 A*B次 select * from A where id in (select id from B) exists适合A表比B表小的情况,exists不会遍历表,只需要查询一次 select * from A where exists(select 1 from B where a.id = b.id)