mysql, LEFT OUTER JOIN 与 LEFT JOIN,RIGHT OUTER JOIN 与RIGHT JOIN ,FULL OUTER JOIN 与 FULL JOIN区别与联系

版权声明:本文为博主原创文章,转载请说明出处 https://blog.csdn.net/u010002184/article/details/87368803

I have seen joins called LEFT OUTER JOIN or RIGHT OUTER JOIN. In some places I have seen LEFT JOIN or RIGHT JOIN. I am confused by this.

I posted a question 2 days ago, but I am unable to understand the links the solutions provide.

Are these types of joins both the same, or is there some difference between the two?

answer1:

There are no difference between both. Refer visual represenation of joins

answer2:

The first link they quoted gives you:

INNER JOIN: returns rows when there is a match in both tables.

LEFT JOIN / LEFT OUTER JOIN: returns all rows from the left table, even if there are no matches in the right table.

RIGHT JOIN / RIGHT OUTER JOIN: returns all rows from the right table, even if there are no matches in the left table.

FULL JOIN / FULL OUTER JOIN / OUTER JOIN: returns rows when there is a match in one of the tables.

SELF JOIN: is used to join a table to itself, as if the table were two tables, temporarily renaming at least one table in the SQL statement.

CARTESIAN JOIN: returns the cartesian product of the sets of records from the two or more joined tables.

The self join is actually not a special join. It just reflects the fact that you can join a table with itself. Doing so you must alias it in order to address the fact that it appears more than once in the same statement.

The cartesian join can be considered as an inner join without a restricting condition. Or you may view an inner join as a cartesian join with an added restriction (the join condition).

参考:

https://stackoverflow.com/questions/15425740/are-left-outer-joins-and-left-joins-the-same

https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins

猜你喜欢

转载自blog.csdn.net/u010002184/article/details/87368803