--sql 2000 如何从表A(总表)中找出表B(分表)中不存在的记录组合假设表A和表B都只有两个字段id,name 如何用一句SQL返回表A中存在的id,name结果集而在表B中不存在的id,name结果集select A.* from A left join B on A.id=B.id and A.name=B.name where B.id is nullselect * from A where not exists(select top 1 * from B where A.ID=B.ID)这两个都可以. --前提:表中不能有text、ntext、image、cursor 数据类型的字段。用CheckSum()最简单:select * from A where checksum(*) not in (select checksum(*) from B)--sql 2005 except
不懂。我就是想把A表和B表的重复ID去掉 求出剩下ID的 Name啊 什么的别的字段信息
select a.* from a where id not in (select id from b)select b.* from b where id not in (select id from a)select a.* from a where id not in (select id from b) union all select b.* from b where id not in (select id from a)
select a.* from a where id not in (select id from b) 用这个就可以了 后面的 union all 不用了
如何从表A(总表)中找出表B(分表)中不存在的记录组合假设表A和表B都只有两个字段id,name
如何用一句SQL返回表A中存在的id,name结果集而在表B中不存在的id,name结果集select A.* from A left join B on A.id=B.id and A.name=B.name where B.id is nullselect * from A where not exists(select top 1 * from B where A.ID=B.ID)这两个都可以.
--前提:表中不能有text、ntext、image、cursor 数据类型的字段。用CheckSum()最简单:select * from A where checksum(*) not in (select checksum(*) from B)--sql 2005
except
union all
select b.* from b where id not in (select id from a)
用这个就可以了 后面的 union all 不用了