当前位置:网站首页>Mysql的七种连接查询方法
Mysql的七种连接查询方法
2022-08-09 13:12:00 【牧歌ing】
Mysql的七种join查询方法

为了大家使用方便代码单独拿出来
左连接 查a表独有和b表共有部分
select * from a left join b on a.key=b.key;
右连接 查b表独有和a表共有部分
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 中的全连接和查a、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
边栏推荐
- JZ7 重建二叉树
- 程序员的七夕怎么过?不会是写代码吧
- 面试攻略系列(四)-- 你不知道的大厂面试
- 处理JSON,fastjson、json-lib简单使用
- puzzle(016.5)逻辑电路
- Professor Chen Qiang the machine learning and R application course chapter 18 assignments
- FFmpeg multimedia file processing (the basic concept of ffmpeg processing stream data)
- FFMPEG multimedia file processing (deletion and renaming of ffmpeg files)
- pyhook3简单应用(1)--实现截图保存功能
- 蓝桥历届真题-门牌制作
猜你喜欢
随机推荐
NC84 完全二叉树结点数
搭建大型分布式服务(二)搭建会员服务
记一次 ERROR scheduler.AsyncEventQueue: Dropping event from queue shared导致OOM
pyhook3简单应用(1)--实现截图保存功能
蓝桥历届真题-既约分数
RobotFramework 之 库与关键字
ArcEngine(九)图形绘制
error Trailing spaces not allowed no-trailing-spaces 9:14 error Unexpected trailing comma
pytest 基础认知
Q_07 词汇表
NC161 二叉树的中序遍历
The sword refers to Offer 56 - II. Number of occurrences of a number in an array II (bit operation)
利用信号灯和共享内存实现进程间同步通信
RobotFramework 之 Evaluate
微服务+微信小程序实现社区服务
Sql之各种Join
WPF 系统托盘 图标闪烁
目标检测类间不平衡问题
R language kaggle game data exploration and visualization
JS本地存储 sessionStorage和localStorage









