t1
1 ajay
2 ravi
3 gaurav
5 naveen
7 sachin
t2
1 ajay
2 ravi
4 alok
6 raja
我需要不匹配的行
3
5
7
4
6
我的查询
select * from t1 A
full outer join t2 B
on A.id=B.id
where not exists(select A.name intersect B.name);
答案 0 :(得分:2)
您需要使用coalesce()
进行过滤:
select coalesce(t.id, t1.id) as unmatched_ids
from t full outer join
t1
on t1.id = t.id
where (t.id is null or t1.id is null);
答案 1 :(得分:0)
早上好,请尝试以下代码。
请注意例如[Name] = ajay,ravi,raja
SELECT A.*,
B.*
from t1 [A]
FULL JOIN t2 [B]
WHERE A.id=B.id
AND A.[Name]<>B.[Name]
希望这会有所帮助,谢谢