好的东西,一定要分享,留着备用
http://www.cnblogs.com/totian/p/7597300.html
sql中的in与not in,exists与not exists的区别以及性能分析:https://blog.csdn.net/baidu_37107022/article/details/77278381
1、in和exists
如果查询的两个表大小相当,那么用in和exists差别不大;如果两个表中一个较小一个较大,则子查询表大的用exists,子查询表小的用in;
2、not in 和not exists
如果查询语句使用了not in,那么对内外表都进行全表扫描,没有用到索引;而not exists的子查询依然能用到表上的索引。所以无论哪个表大,用not exists都比not in 要快。