【代码保留】exists和not exists
代码功能:查询所有的是7或8并且不是4和5的项
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
后话:
exists和not exists与in和not in的区别:
1、效率上的,这一点google一下会有很多
2、使用上的区别:
由in转换成exists的情况:
在in前面通常有t.***id in ( select ***id from table1 a where *=* )
转换则为:exists ( select ***id from table1 a where *=* and a.***id=t.***id )
not exists对应not in只是在exists前加not,其余相同。
3、注意以上代码中or关键字,如果有or,通常需要在or的左右两侧的条件之间进行括号。而在in中通常使用与不使用效果相同,但在exists中则会有所区别。
posted on 2007-11-23 16:44 volnet(可以叫我大V) 阅读(390) 评论(0) 编辑 收藏 举报