MyBatis知识梳理

select * from aaa a where exists (select * from bbb b where b.id=a.id)

相当于 

select * from aaa where id in (select id from bbb)

加 NOT 相当于 

select * from aaa where id not in (select id from bbb)

只是exists的执行效率比in高的多,in要去匹配全表,exists只匹配索引

你可能感兴趣的:(MyBatis知识梳理)