简单 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)