mysql 不支持 直接写full outer join 或者 full join来表示全外连接但是可以用left right union right 代替。
全外连接图(非原创图)
下面的是全外连接例子:
select * from table a A(A为别名)LEFT JOIN table b B on A.id=B.id
union
select * from table a A RIGHT JOIN table b B on A.id=B.id;
这个是全外连接去除公共部分,两个查询语句都要加上where 只加一句where 是无效的。
select * from table a A(A为别名)LEFT JOIN table b B on A.id=B.id
where B.id is null
union
select * from table a A RIGHT JOIN table b B on A.id=B.id
where A.id is null;
全外连接去除公共部分图(非原创图)