Home > Database > Mysql Tutorial > Difference between left, right and full outer join

Difference between left, right and full outer join

WBOY
Release: 2023-08-27 10:13:08
forward
920 people have browsed it

Difference between left, right and full outer join

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
Copy after login

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
Copy after login

Full outer join

It fetches all rows from both tables.

It is similar to performing an "inner join all unmatched rows in the left table all unmatched rows in the right table".

No data will be lost in this operation.

Example:

SELECT [column_1, column_2, ….]
FROM table_1
FULL OUTER JOIN table_2 ON
table_1.matching_column = table_2.matching_column
Copy after login

The above is the detailed content of Difference between left, right and full outer join. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template