内联接、外联接和交叉联接_内联接和外联接之间有什么区别?

内联接、外联接和交叉联接

内联接、外联接和交叉联接

Sql is the language where a lot of data can be get with different logic. In an enterprise environment we may need to use complex SQL queries to get meaningful data. Inner is one of the logic where we join two tables with different magic.

Sql是使用不同逻辑可以获取大量数据的语言。 在企业环境中,我们可能需要使用复杂的SQL查询来获取有意义的数据。 内在是将两个具有不同魔力的表联接在一起的逻辑之一。

示例表 (Example Tables)

In order to understand Inner and Outer Joins we will use following example tables with their data. We will use two tables those named Personels and Persons

为了理解内部联接和外部联接,我们将使用以下示例表及其数据。 我们将使用两个名为PersonelsPersons

MariaDB [test]> SELECT LastName FROM Personels; 
+----------+ 
| LastName | 
+----------+ 
| C        | 
| D        | 
| E        | 
+----------+ 
3 rows in set (0.00 sec)
MariaDB [test]> SELECT LastName FROM Persons; 
+----------+ 
| LastName | 
+----------+ 
| A        | 
| B        | 
| C        | 
| NULL     | 
+----------+ 
4 rows in set (0.00 sec)

内部联接 (Inner Join)

If we inner join Persons with Personels we will get only intersection of the given fields. In this example we want to get the LastName column intersection in two tables Persons and Personels .

如果我们内部将“人员与人员”联接在一起,则将仅获得给定字段的交集。 在此示例中,我们希望在两个表PersonsPersonels获得LastName列的交集。

> SELECT Persons.LastName FROM Persons INNER JOIN Personels on Persons.LastName = Personels.LastName;           
+----------+ 
| LastName | 
+----------+ 
| C        | 
+----------+ 
1 row in set (0.00 sec)

右外连接 (Right Outer Join)

The right outer join will return all entries in left table and

右外部联接将返回左表中的所有条目,并且

> SELECT Persons.LastName FROM Persons RIGHT OUTER JOIN Personels on Persons.LastName = Personels.LastName;       
+----------+ 
| LastName | 
+----------+ 
| C        | 
| NULL     | 
| NULL     | 
+----------+ 
3 rows in set (0.00 sec)

左外连接 (Left Outer Join)

> SELECT Persons.LastName FROM Persons LEFT OUTER JOIN Personels on Persons.LastName = Personels.LastName;     
+----------+ 
| LastName | 
+----------+ 
| C        | 
| A        | 
| B        | 
| NULL     | 
+----------+ 
4 rows in set (0.00 sec)

内联接和外联接之间有什么区别? 信息移植 (What is The Difference Between Inner and Outer Join? Infografic)

What is The Difference Between Inner and Outer Join? Infografic
What is The Difference Between Inner and Outer Join? Infografic
内联接和外联接之间有什么区别? 信息移植
LEARN MORE  SQL "Select Into" Statement Usage Tutorial
了解更多SQL“选择入”语句用法教程

翻译自: https://www.poftut.com/difference-inner-outer-join/

内联接、外联接和交叉联接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值