如有两张相同表结构的表:
test表:
test1表:
现在要找出两张表有差异的数据,需要用minus及union的方式查找出来,语句如下:
select t1.* from
(select * from test
minus
select * from test1) t1
union
select t2.* from
(select * from test1
minus
select * from test) t2;
查询结果如下,红框部分的数据就是有差异的内容。
select * from A minus select * from B;
select * from B minus select * from A;
比较表结构相同的两表之间的差异用minus。希望对你有帮助。
望采纳。
字段关联FULL JOIN
SELECT A.AA,B.AA FROM A FULL JOIN B ON A.AA = B.AA where A.AA IS NULL OR B.AA IS NULL就可以查询出不一样的了
est表:
test1表:
现在要找出两张表有差异的数据,需要用minus及union的方式查找出来,语句如下:
select t1.* from(select * from testminusselect * from test1) t1union select t2.* from(select * from test1minusselect * from test)
1
select
t1.*
from
(select
*
from
test
minus
select
*
from
test1)
t1
union
select
t2.*
from
(select
*
from
test1
minus
select
*
from
test)
t2;
select
t1.*
from
(select
*
from
test
minus
select
*
from
test1)
t1
union
select
t2.*
from
(select
*
from
test1
minus
select
*
from
test)
t2;
红框部分的数据就是有差异的内容。