当前位置: 首页 > 新闻动态 > 技术教程

左、右和完全外连接之间的区别

作者:WBOY 浏览: 发布日期:2023-08-27
[导读]:Inthispost,wewillunderstandthedifferencebetweenleftouterjoin,rightouterjoin,andfullouterjoin.LeftOuterJoinItfetchesalltherowsfromthetableontheleft.Itissameas‘InnerJoin+alltheunmatchedrowsfromthelefttable’.Thedatathatisn’

In this post, we will understand the difference between left outer join, right outer join, and full outer join.

Left Outer Join

It fetches all the rows from the table on the left.

It is same as ‘Inner Join + all the unmatched rows from the left table’.

The data that isn’t matched on the right table is lost.

Example:

SELECT [column_1, column_2, ….]
FROM table_1
LEFT OUTER JOIN table_2 ON
table_1.matching_column = table_2.matching_column

Right Outer Join

It fetches all the rows of the table on the right.

It is similar to performing ‘Inner Join + all of the unmatched rows from the right table’.

The unmatched data from the left table is lost.

Example:

SELECT [column_1, column_2, ….]
FROM table_1
RIGHT OUTER JOIN table_2 ON
table_1.matching_column = table_2.matching_column

全外连接

它从两个表中获取所有的行。

它类似于执行“内连接 + 左表中所有不匹配的行 + 右表中所有不匹配的行”。

在此操作中不会丢失任何数据。

示例:

SELECT [column_1, column_2, ….]
FROM table_1
FULL OUTER JOIN table_2 ON
table_1.matching_column = table_2.matching_column
免责声明:转载请注明出处:http://www.sczxchw.cn/news/514440.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!