MySQL七种join理论

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;

 

posted @ 2019-08-10 15:12  风来与你安  阅读(753)  评论(0编辑  收藏  举报