現(xiàn)在有2張表一樣的格式,但是一張表數(shù)據(jù)有減少,要求另一張表也得同步表。
網(wǎng)上看到過(guò)這樣的方式查詢表差異
select * from ta left join tb on ta.id=tb.id where tb.id is null
因?yàn)楝F(xiàn)在要查詢的表是2個(gè)key(id和idx),本想也采用以下方式來(lái)查詢
select * from ta left join tb on (ta.id=tb.id and ta.idx=tb.idx) where tb.idx is null
自己沒(méi)有查出差異,一開(kāi)始以為2個(gè)key的時(shí)候不能用
最后自己發(fā)現(xiàn),是tb.idx is null 用了tb.idx = null方法了
參考鏈接:http://www.cnblogs.com/xwdreamer/archive/2012/06/01/2530597.html