首頁 >資料庫 >mysql教程 >左、右和完全外連接之間的區別

左、右和完全外連接之間的區別

WBOY
WBOY轉載
2023-08-27 10:13:08922瀏覽

左、右和完全外連接之間的區別

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刪除