not in 和 not exists

--一个连接查询,在Bn_scenes中去掉一些记录。
select * from UFSystem..BN_Scenes where bSysVisible='1' and cBizSceneId not in (select cBizSceneId from BN_ScenesCustom where userid='likun5') order by iorder asc

 

 

使用exists

select * from UFSystem..BN_Scenes where bSysVisible='1' 
and  not exists(select 
cBizSceneId from BN_ScenesCustom where userid='demo' AND BN_Scenes.cBizSceneId=BN_ScenesCustom.cBizSceneId) 

两个查询执行的结果和效率一样。

posted @ 2013-05-09 19:22  viola  阅读(196)  评论(0编辑  收藏  举报