現在有2張表一樣的格式,但是一張表數據有減少,要求另一張表也得同步表。
網上看到過這樣的方式查詢表差異
select * from ta left join tb on ta.id=tb.id where tb.id is null
因為現在要查詢的表是2個key(id和idx),本想也采用以下方式來查詢
select * from ta left join tb on (ta.id=tb.id and ta.idx=tb.idx) where tb.idx is null
自己沒有查出差異,一開始以為2個key的時候不能用
最后自己發現,是tb.idx is null 用了tb.idx = null方法了
參考鏈接:http://www.cnblogs.com/xwdreamer/archive/2012/06/01/2530597.html