mysql中的完全外部连接 [英] full outer join in mysql
本文介绍了mysql中的完全外部连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
在MySQL中完全外部连接
Possible Duplicate:
Full Outer Join in MySQL
有两个表tableA和table B 两个表都有公共列ID
There are two tables tableA and table B both the tables have common column id
我们想要得到所有记录都在A中但不在B中的结果 以及B中存在但A中不存在的所有记录
We want to get the results which are having all records in A but not in B and all records which exists in B but not in A
关于, 奇塔·基兰(Chinta kiran)
Regards, Chinta kiran
推荐答案
您正在寻找MINUS SET OPERATOR:
You are looking for MINUS SET OPERATOR:
我们要获取所有记录都在A中但不在B中的结果"
简便方法:
SELECT A.*
FROM A
WHERE A.id not in (SELECT id FROM B)
具有完全外部联接
SELECT A.*
FROM A full outer join B on A.id = B.id
WHERE B.id is Null
正确的方法:
SELECT A.*
FROM A left outer join B on A.id = B.id
WHERE B.id is Null
将A更改为B,将B更改为A,以获取所有记录都在B中但不在A中的结果.
Change A to B and B to A for in order to get the results which are having all records in B but not in A.
这篇关于mysql中的完全外部连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文