MySQL七种join理论

我们两清 提交于 2021-02-13 03:39:26

1. 内连接

select * from A inner join B where A.key=B.key;

 

2. 左连接

select * from A left join B on A.key=B.key where B.key is null;

 

3. 右连接

select * from A right join B on A.key=B.key where A.key is null;

 

4. 左外连接

select * from A left join B on A.key=B.key;

 

5. 右外连接

 

select * from A right join B on A.key=B.key

 

6. 全外连接

select * from A left join B where A.key=B.key union select * from A right join B where A.key=B.key;

 

7. 两表独有的数据集

 

select * from A left join B on A.key=B.key where B.key is null 

union

select * from A right join B on A.key=B.key where A.key is null;

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!