一个看似简单的SELECT,可惜我写不来.立刻结贴
--A表
id date TEMP
a01 2013-04-05 fda
a02 2013-04-05 dsfdsaf
a01 2013-04-06 fdsafdasfd
a02 2013-04-06 fdsafdasfd
--B表
id date temp
a01 2013-04-05 aaa
a02 2013-04-05 bbb
a01 2013-04-06 ccc
---------------------------------
求A表存在,但B表不存在的数据,判断(ID,date) 2个字段.
即找到以下这条结果.
a02 2013-04-06
------解决方案--------------------select * from A left join B on a.id=b.id and a.date=b.date where b.id is null
------解决方案--------------------select * from A where not exists(select 1 from B where id=A.id and data=A.data)
------解决方案--------------------SELECT A.id,A.date
FROM A
WHERE NOT EXISTS(SELECT 1 FROM B WHERE A.id = b.id AND a.[date] = b.[date])