--tryselect A.* from 表A A where exists (select 1 from B表 where A.id<>B.Id) union all select A.* from 表A A where exists (select 1 from B表 B where A.id=B.id and A.num<>B.num)
zlp321002(好好学习,贴贴向上) 請問;select 1 啥意思.
这样应该比较清楚一点: select a.id, a.num from a left join b on a.id=b.id where b.id is null union all select b.id, b.num from a right join b on a.id=b.id where a.id is null union all select a.id, a.num from a inner join b on a.id=b.id and a.num<>b.num
select B.* from B where B.id not in(select id from A) union all select A.* from A where A.id not in(select id from B) union select A.* from A,B where A.id=B.id and A.num<>B.num
SELECT * FROM A WHERE ID NOT IN (SELECT ID FROM B) UNION ALL SELECT * FROM B WHERE ID NOT IN (SELECT ID FROM A)SELECT * FROM A LEFT JOIN B ON A.ID=B.ID AND A.NUM<>B.NUM
from 表A A
where exists (select 1 from B表 where A.id<>B.Id)
union all
select A.*
from 表A A
where exists (select 1 from B表 B where A.id=B.id and A.num<>B.num)
請問;select 1 啥意思.
select a.id, a.num
from a left join b on a.id=b.id
where b.id is null
union all
select b.id, b.num
from a right join b on a.id=b.id
where a.id is null
union all
select a.id, a.num
from a inner join b on a.id=b.id and a.num<>b.num
select B.*
from
B
where B.id not in(select id from A)
union all
select A.*
from
A
where A.id not in(select id from B)
union
select A.*
from
A,B
where A.id=B.id and A.num<>B.num
WHERE ID NOT IN (SELECT ID FROM B)
UNION ALL
SELECT * FROM B
WHERE ID NOT IN (SELECT ID FROM A)SELECT * FROM A
LEFT JOIN B ON A.ID=B.ID AND A.NUM<>B.NUM