当前位置:网站首页>Mysql seven connection query methods

Mysql seven connection query methods

2022-08-09 14:18:00 Pastoral

Mysql的七种join查询方法

在这里插入图片描述

Take out for everybody easy to use code alone

左连接 查a表独有和bThere are some table

select * from a left join b on a.key=b.key;

右连接 查b表独有和aThere are some table

select * from a right join b on a.key=b.key;

内连接 查a、b共有部分

select * from a inner join b on a.key=b.key;

只查a独有的部分

select * from a left join b on a.key=b.key where b.key is null;

只查b独有的部分

select * from a right join b on a.key=b.key where a.key is null; 

全连接

select * from a left join b on a.key=b.key union select * from a right join b on a.key=b.key;

查a、b共有的部分

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;

oracle In the whole connection and thea、b共有部分

select * from a full outer join b on a.key=b.key
select * from a full outer join b on a.key=b.key where a.key is null or b.key is null
原网站

版权声明
本文为[Pastoral]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208091312253214.html