对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之间的区别相关推荐

  1. 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 ...

  2. 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 ...

  3. left join 和 left outer join 有什么区别

    left join 是left outer join的简写,left join默认是outer属性的. Inner Join 逻辑运算符返回满足第一个(顶端)输入与第二个(底端)输入联接的每一行.这个 ...

  4. 图解SQL的inner join(join)、left join、right join、full outer join、union、union all的区别...

    对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚.Codin ...

  5. 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= ...

  6. 图解SQL的inner join、left join、right join、full outer join、union、union all的区别

    对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚.Codin ...

  7. Mysql: 图解 inner join、left join、right join、full outer join、union、union all的区别

    对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对 于Select出来的结果集是什么样子有点不是很清楚.Codi ...

  8. 图解SQL inner join、left join、right join、full outer join、union、union all的区别

    对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对 于Select出来的结果集是什么样子有点不是很清楚.Codi ...

  9. full outer join 与full join的区别_基础小白的SQL的JOIN语法解析

    总的来说,四种JOIN的使用/区别可以描述为: left join 会从左表(shop)那里返回所有的记录,即使在右表(sale_detail)中没有匹配的行. right outer join 右连 ...

  10. SQL OUTER JOIN概述和示例

    This article will provide a full overview, with examples of the SQL Outer join, including the full, ...

最新文章

  1. [ImportNew]Java中的Timer类和TimerTask类
  2. .h file not found
  3. Perhaps you are running on a JRE rather than a JDK? 关于 idea maven 缓存的问题 清理 idea maven 缓存
  4. 面试中如何剔除“鱼目混珠”程序员?
  5. oracle——监听(二、sqlplus连接数据库)
  6. 什么是粘包?socket 中造成粘包的原因是什么? 粘包的处理方式
  7. The c program language 1
  8. ESP8266,电脑作为TCP SERVER,8266发数据给电脑
  9. Apache Doris 0.11.x 版本升级
  10. 雅虎的无奈,将关闭地图、Pipes、GeoPlanet和PlaceSpotter APIs、一些区域网站
  11. CAD打开文件一直转圈圈什么情况?如何能彻底解决?
  12. 全国主要地级市按拼音排序json数据
  13. 求一个数取log2的较小的整数 Ilog2
  14. SuperMap iClient3D for WebGL教程(影像篇)-SingleTileImageryProvider
  15. Linux 中的文件类型
  16. 二值图像的噪点去除算法
  17. 抖音seo优化源代码搭建+抖音小程序私有化开源部署
  18. 临近年底企业利润高、所得税税负重,如何合规解决?
  19. 某资产管理公司部署贷前征信调查报表系统实录
  20. 查看及配置交换机管理地址

热门文章

  1. cordova android项目自定义插件及使用(二)
  2. [置顶] Android代码-----检测手机耳机插拔
  3. Windows7与Window2008 64位IIS7上面配置操作Excel
  4. nice和renice命令详解
  5. 【字符编码系列】常用的几种字符编码(GBK,UTF-8,UTF-16)
  6. HENXU-SOA的业务规划和建模方法之七——SOA的方法融合
  7. Golang unsafe包使用笔记
  8. 《IS-IS网络设计解决方案》一导读
  9. 2010年04月 小记(MVC2validation, svn)
  10. 文档流、脱离文档流分析