Mysql常用sql语句(17)- left / right join 外连接
发布时间:2020-12-12 02:13:58 所属栏目:MySql教程 来源:网络整理
导读:测试必备的Mysql常用sql语句系列 https://www.cnblogs.com/poloyy/category/1683347.html ? 前言 外连接分为 两种 :left join、right join 外连接显示的内容要比内连接多,是 对内连接的补充 left join的 主表 是左表, 从表 是右表 right join的 主表 是右
测试必备的Mysql常用sql语句系列 https://www.cnblogs.com/poloyy/category/1683347.html ? 前言
? left join、right join 的语法格式SELECT <字段名> FROM <表1> LEFT OUTER JOIN <表2<ON子句> RIGHT > 语法格式说明
? 先看看dept、emp表有什么数据dept表emp表? left join 的栗子SQL分析
select * from emp as a join dept as b on a.dept_id = b.id; ? left join + where 的栗子SQL分析
= b.id where b.id is null; 知识点
? right join 的栗子= b.id;
SQL分析
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |