表一 user(用户表)
表二 dept(部门表)
外连接
select * from user u left join dept d on u.dept = d.id where d.id is null;
左外连接
select * from user u left join dept d on u.dept = d.id;
全连接
-- 左独有数据
select * from user u left join dept d on u.dept = d.id where d.id is null
union
-- 右独有数据
select * from user u right join dept d on u.dept = d.id where u.id is null;
全外连接
-- 左外
select * from user u left join dept d on u.dept = d.id
union
-- 右外
select * from user u right join dept d on u.dept = d.id;
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。