`
acen.chen
  • 浏览: 154730 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

inner join&left outer join&right outer join

阅读更多
left outer join === left join
rirht outer join === right join
full outer join === full join
inner join  === A = B
 
no full inner join
no left inner join
no right inner join
 
they are the same as the "inner join"
 
 
 
 
Join types

By default, a join is assumed to be an inner join. You can also request other types of joins by clicking Join Type on the Joins page of SQL Assist. The following types of joins are available:

  • Inner join
  • Left outer join
  • Right outer join
  • Full outer join

7 An inner join is join method in which 7 a column that is not common to all of the tables being joined is dropped from 7 the resultant table. If your database supports the OUTER JOIN keywords, you 7 can extend the inner join to add rows from one table that have no matching 7 rows in the other table.

For example, you want to join two tables to get the last name of the manager for each department. The first table is a Department table that lists the employee number of each department manager. The second table is an Employee table that lists the employee number and last name of each employee. However, some departments do not have a manager; in these cases, the employee number of the department manager is null. To include all departments regardless of whether they have a manager, and the last name of the manager, if one exists, you create a left outer join. The left outer join includes rows in the first table that match the second table or are null. The resulting SQL statement is as follows:

SELECT DEPTNO, DEPTNAME, EMPNO, LASTNAME
   FROM DEPARTMENT LEFT OUTER JOIN EMPLOYEE
      ON MGRNO = EMPNO 

A right outer join is the same as a left outer join, except that it includes rows in the second table that match the first table or are null. A full outer join includes matching rows and null rows from both tables.

For example, you have two tables, Table 1 and Table 2, with the following data:

Table 1. Table 1 Column A Column B
1 A
2 B
3 C
Table 2. Table 2 Column C Column D
2 X
4 2

You specify a join condition of Column A = Column C. The result tables for the different types of joins are as follows:

Inner join
Table 3. Inner join result table Column A Column B Column C Column D
2 B 2 X
Left outer join
Table 4. Left outer join result table Column A Column B Column C Column D
1 A null null
2 B 2 X
3 C null null
Right outer join
Table 5. Right outer join result table Column A Column B Column C Column D
2 B 2 X
null null 4 2
Full outer join
Table 6. Full outer join result table Column A Column B Column C Column D
1 A null null
2 B 2 X
3 C null null
null null 4 2

If you specify value (a,c), you obtain the following result:

Table 7. Result of value (a,c) Value (a,c)
1
2
3
4
Related concepts
分享到:
评论

相关推荐

    inner join、 left join 、right join、 outer join之间的区别

    inner join、 left join 、right join、 outer join之间的区别

    SQL中的left outer join,inner join,right outer join用法详解

    * FULL OUTER JOIN:LEFT OUTER 和 RIGHT OUTER 中所有行的超集。 内连接(Inner Join) 内连接是最常见的一种连接,它也被称为普通连接,而 E.FCodd 最早称之为自然连接。例如: SELECT * FROM t_institution i ...

    SQL联合查询inner join、outer join和cross join的区别详解

    这三者的区别很多人都应该不是很清楚,包括我自己,下面我们一起来看看,如果你使用join连表,缺陷的情况下是inner join,另外,开发中使用的left join和right join属于outer join,而outer join还包括full join....

    关于sql的left join,right join,inner join,outerjoin

    NULL 博文链接:https://appofis.iteye.com/blog/467692

    SQL中inner join、outer join和cross join的区别

    我也是别人问起,才查找资料看了下,跟自己之前的认识差不多,如果你使用join连表,缺陷的情况下是inner join,另外,开发中使用的left join和right join属于outer join,另外outer join还包括full join.下面我通过...

    join on 语句及扩展

    Join on/inner join on/full join on/full outer join on/left join on/right join on/cross join on; 在使用jion时,on和where条件的区别;

    sql中join总结

    SQL中大概有这么几种JOIN:cross joininner joinleft outer joinright outer joinfull outer join他们都是基于cross join(笛卡尔乘积),举例说明

    SQL多表连接查询、多表关联

    inner join,full outer join,left join,right jion 内部连接 inner join 两表都满足的组合 full outer 全连 两表相同的组合在一起,A表有,B表没有的数据(显示为null),同样B表有 A表没有的显示为(null) A表 left ...

    【SQL高级(三)】【SQL 连接(JOIN)】

    文章目录SQL 连接(JOIN)不同的 SQL JOINSQL INNER JOIN 关键字SQL LEFT JOIN 关键字SQL RIGHT JOIN 关键字SQL FULL OUTER JOIN 关键字 SQL 连接(JOIN) SQL join 用于把来自两个或多个表的行结合起来。 下图展示了 ...

    Which SQL statement is the trump card to the senior software developer

    Within so many kinds of DML statements in SQL, I think four kinds of them, including Case When, Left Outer Join/Left Join / Right Outer Join /Right Join/ Inner Join, WITH AS and UNION/UNION ALL, are ...

    Mycat与Mysql跨库JOIN与性能测试

    Mysql提供了多种JOIN类型,包括INNER JOIN、LEFT JOIN、RIGHT JOIN、FULL JOIN等。这些JOIN类型可以满足不同的应用场景。 1.1 Mysql分库操作 Mysql提供了多种分库操作,包括水平分库、垂直分库和混合分库。水平分...

    用“万能数据库查询分析器”对 SQLite 进行测评

    在SQL(Structured Query Language)语言DML中,有四大语句堪称其精髓部分,分别是CASE WHEN语句,Left Outer Join | Left Join | Right Outer Join | Right Join | Inner Join语句,WITH AS语句,UNION、UNION ALL...

    LINQ to SQL语句之Join和Order By

    [t0].[Discontinued] FROM [dbo].[Products] AS [t0] LEFT OUTER JOIN [dbo].[Suppliers] AS [t1] ON [t1].[SupplierID] = [t0].[SupplierID] WHERE ([t1].[Country] = @p0) AND ([t0].[UnitsInStock] = @p1) -- @p0...

    SQL语句多表查询

    1、左连接 left join 或 left outer join 2、右连接 right join 或 right outer join 3、完全外连接 full join 或 full outer join 二、内连接 join 或 inner join 三、交叉连接 cross join 四、两表关系为一对多...

    我的 ORM 框架

    SELECT 语句支持 INNER JOIN、LEFT OUTER JOIN 和RIGHT OUTER JOIN 多表联合查询,但不支持同一表的联合查询。 代码中只实现了 SQL Server 的相关操作。其它数据库可以扩展。 希望 CSDN 中的大神给我一些建议。小弟...

    MySQL常见面试题(表连接类型,count(*),count(列),count(1)的区别,索引,存储引擎,锁,优化)

    部分内容展示: ...右外连接:使用right outer join,表示即使右表存在未关联数据,也被查询出来。在left outer join右侧的表叫做右表。(能够查询出关联数据和右表没有关联的数据,在右表的下方进行展示)

    sql 外联、内联简单的例子

    FROM子句关键字 相应的结果集 CROSS JOIN 笛卡尔乘积(所有可能的行对) INNER JOIN 仅对满足连接条件的CROSS中的列 LEFT OUTER JOIN 一个表满足条件的行,...FULL OUTER JOIN LEFT OUTER 和 RIGHT OUTER中所有行的超集

    软件开发高手须掌握的4大SQL精髓语句(二)

    随着计算机在社会各领域应用的深入,软件开发人员不得不面临着或多或少的数据处理、数据库访问。...下面就讲述一下其中之一, Left Outer Join | Left Join | Right Outer Join | Right Join | Inner Join 语句的用法。

    MySQL中基本的多表连接查询教程

    一、多表连接类型 1. 笛卡尔积(交叉连接) ...一般使用LEFT [OUTER] JOIN或者RIGHT [OUTER] JOIN  2. 内连接INNER JOIN 在MySQL中把I SELECT * FROM table1 CROSS JOIN table2 SELECT * FROM table1 JOIN table2 SELE

Global site tag (gtag.js) - Google Analytics