A表记录如 name no times date 张三 002 1 2008-12-01 张三 002 2 2008-12-22 张三 002 3 2009-12-01 李四 010 1 2005-01-01 王五 022 2 2004-01-23 B表记录如 name no times date 张三 002 1 2008-12-01 张三 002 2 2008-12-22 张三 002 3 2009-12-01 张三 002 4 2010-12-01 张三 002 5 2010-12-22 张三 002 5 2010-12-29 (次数一样,日期不一样) 李四 010 2 2005-12-23 王五 022 4 2007-01-23 王五 022 5 2007-01-25
我要查出B表里A表没有的记录。。。这个SQL怎么写啊。。
select * from b where not exists( select 1 from a where a.name=b.name and a.no=b.no and a.times=b.times and a.date=b.date) SELECT * from B EXCEPT SELECT * from A;
SQL code: select * from tb except select * from ta
SQL code: select * from b where not exists(select 1 from a where name=b.name and no=a.no and times=a.times and [date]=t.[date])