首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

容易 NOT EXISTS

2013-04-26 
简单 NOT EXISTS表1)331501489932238620233150148993323861763394601474L24172993394601474M2417298339460

简单 NOT EXISTS
表1)
3315014899322386202
3315014899332386176
3394601474L2417299
3394601474M2417298
3394601474S2417297
3394601474XL2417300
3315153699282396457
3315153699282396646
3315153699292396665
3315153699292396458
3315153699282396459
3315153699282396460
3315153699292396461
3315153699292396462
表2)
3315153699282396457
3315153699282396646
3315153699292396665
3315153699292396458
结果是
表1)里面的
3315153699282396459
3315153699282396460
3315153699292396461
3315153699292396462
第一列与表2相同,第二列与表2不相同 NOT?EXISTS?
[解决办法]
select * from table1 a
where exists (select 1 from table2 b where b.col1 = a.col1)
and not exists (select 1 from table2 c where c.col1 = a.col1 and c.col2 = a.col2)

热点排行