inner join、 left join 、right join、full outer join之间的区别
对inner join、left join、right join和full join的学习是在大学时候,近来公司常使用它们,对它们的认识随着时间的逝去已渐趋渐远,借此机会重新温习一下:
table1 table2
id1 class_name id2 name
01 一年级 01 张三
02 二年级 02 李四
03 三年级 04 王五
1、able1 left join table2 其连接的记录数与table1表的记录数相等,此时等价于table2 right join table1,例如 select t1.* ,t2.* from table1 t1 left join table2 t2 on id1= id2 结果是:
id1 class_name id2 name
01 一年级 01 张三
02 二年级 02 李四
03 三年级 NULL NULL
2、able1 right join table2 其连接的记录数与table2表的记录数相等,此时等价于table2 left join table1,例如 select t1.*,t2.* from table1 t1 right join table2 t2 on id1 = id2 结果是:
id1 class_name id2 name
01 一年级 01 张三
02 二年级 02 李四
NULL NULL 04 王五
3、table1 inner join table2 其连接的记录数是table1和table2表on条件都有的记录数,即两表都有的数据,例如 select t1.* ,t2.* from table1 t1 inner join table2 t2 on t1 = t2 结果是:
id1 class_name id2 name
01 一年级 01 张三
02 二年级 02 李四
4、table1 full join table2 其连接的记录数是两表所有的总共的数据,例如 select t1.* , t2.* from table1 t1 full join table2 t2 结果是:
id1 class_name id2 name
01 一年级 01 张三
02 二年级 02 李四
03 三年级 NULL NULL
NULL NULL 04 王五
inner join、 left join 、right join、full outer join之间的区别相关推荐
- oracle full outer join,oracle 内连接(inner join)、外连接(outer join)、全连接(full join)...
建表语句: create table EMPLOYEE ( EID NUMBER, DEPTID NUMBER, ENAME VARCHAR2(200) ) create table DEPT ( D ...
- sql out apply_在SQL Server中CROSS APPLY和OUTER APPLY之间的区别
sql out apply SQL Server supports table valued functions, what are functions that return data in the ...
- left join 和 left outer join 有什么区别
left join 是left outer join的简写,left join默认是outer属性的. Inner Join 逻辑运算符返回满足第一个(顶端)输入与第二个(底端)输入联接的每一行.这个 ...
- 图解SQL的inner join(join)、left join、right join、full outer join、union、union all的区别...
对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚.Codin ...
- SQL中的left outer join,inner join,right outer join用法 (左右内连接)
SQL语句中的left outer join,inner join,right outer join用法 left outer join=left join , right outer join= ...
- 图解SQL的inner join、left join、right join、full outer join、union、union all的区别
对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚.Codin ...
- Mysql: 图解 inner join、left join、right join、full outer join、union、union all的区别
对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对 于Select出来的结果集是什么样子有点不是很清楚.Codi ...
- 图解SQL inner join、left join、right join、full outer join、union、union all的区别
对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对 于Select出来的结果集是什么样子有点不是很清楚.Codi ...
- full outer join 与full join的区别_基础小白的SQL的JOIN语法解析
总的来说,四种JOIN的使用/区别可以描述为: left join 会从左表(shop)那里返回所有的记录,即使在右表(sale_detail)中没有匹配的行. right outer join 右连 ...
- SQL OUTER JOIN概述和示例
This article will provide a full overview, with examples of the SQL Outer join, including the full, ...
最新文章
- [ImportNew]Java中的Timer类和TimerTask类
- .h file not found
- Perhaps you are running on a JRE rather than a JDK? 关于 idea maven 缓存的问题 清理 idea maven 缓存
- 面试中如何剔除“鱼目混珠”程序员?
- oracle——监听(二、sqlplus连接数据库)
- 什么是粘包?socket 中造成粘包的原因是什么? 粘包的处理方式
- The c program language 1
- ESP8266,电脑作为TCP SERVER,8266发数据给电脑
- Apache Doris 0.11.x 版本升级
- 雅虎的无奈,将关闭地图、Pipes、GeoPlanet和PlaceSpotter APIs、一些区域网站
- CAD打开文件一直转圈圈什么情况?如何能彻底解决?
- 全国主要地级市按拼音排序json数据
- 求一个数取log2的较小的整数 Ilog2
- SuperMap iClient3D for WebGL教程(影像篇)-SingleTileImageryProvider
- Linux 中的文件类型
- 二值图像的噪点去除算法
- 抖音seo优化源代码搭建+抖音小程序私有化开源部署
- 临近年底企业利润高、所得税税负重,如何合规解决?
- 某资产管理公司部署贷前征信调查报表系统实录
- 查看及配置交换机管理地址
热门文章
- cordova android项目自定义插件及使用(二)
- [置顶] Android代码-----检测手机耳机插拔
- Windows7与Window2008 64位IIS7上面配置操作Excel
- nice和renice命令详解
- 【字符编码系列】常用的几种字符编码(GBK,UTF-8,UTF-16)
- HENXU-SOA的业务规划和建模方法之七——SOA的方法融合
- Golang unsafe包使用笔记
- 《IS-IS网络设计解决方案》一导读
- 2010年04月 小记(MVC2validation, svn)
- 文档流、脱离文档流分析