日期:2014-05-17  浏览次数:20445 次

sql查2张表出不相同部分
a表
name 
a
b
c
b表
name1
aa
a
a1
b
c
c1

要查出
aa
a1
c1


------解决方案--------------------
SQL code
select name1 from b表 except select name from a表

------解决方案--------------------
探讨
LZ要查两张中不同的,而不是其中一个表的不同

SQL code


select name from a except select name1 from b
union
select name1 from b except select name from a

------解决方案--------------------
SQL code
select distinct a.search from a full join b 
on checksum(a.search)=checksum(b.Name)
where a.id is null or b.id is NULL

------解决方案--------------------
没有什么好的方法了?
------解决方案--------------------
SQL code

select name from a where not exist(select * from b where name1=a.name)
union
select name1 from b where not exist (select * from a where name=b.name1)