首页 > 数据库 > mysql教程 > 左、右和完全外连接之间的区别

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

WBOY
发布: 2023-08-27 10:13:08
转载
920 人浏览过

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

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
登录后复制

以上是左、右和完全外连接之间的区别的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:tutorialspoint.com
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板