SQL2000源数据和目标数据行对比
SQL2000从源表查对比,查找出在目标表中没有的行.
需判断三个条件同时成立时
vipmaterialid,viptraderid,vipbmclid
源表slaedetail中的列
vipmaterialid,viptraderid,vipbmclid,vipjcquantity
1 , 2 , 33 , 999
3 , 22 , 23 , 888
4 , 3 , 123 , 777
视图vip_wwjcquantity 被对比视图
vipmaterialid,viptraderid,vipbmclid,vipjcquantity
1 , 2 , 33 , 77777
4 , 3 , 123, 88888
要求结果如下:
vipmaterialid,viptraderid,vipbmclid,vipjcquantity
3 , 22 , 23 , 888
------解决方案--------------------select * from slaedetail a where not exists (select 1 from vip_wwjcquantity b where a.vipmaterialid=b.vipmaterialid and a.viptraderid=b.viptraderid and a.vipbmclid=b.vipbmclid)