【望朋友们一起分享下工作中遇到的sql写法】
一、想查询x表中有但是y表中没有的vin
1、
select x.vinno,y.vin from tr_carinfo x left join tr_carinfo_keypart y on (x.vinno=y.vin and y.vin is null)
2、
select x.vinno from tr_carinfox,tr_carinfo_keypart y where x.vinno=y.vin(+) and y.vin is null
3、
select x.vinno,y.vin from tr_carinfo xleft join tr_carinfo_keypart y on (x.vinno=y.vin ) where y.vin is null
结果:方法1、查出来的会多很多数据,没有达到效果。
方法2、3、达到效果