What is the difference between LEFT JOIN
and LEFT OUTER JOIN
?
There really is no difference between a LEFT JOIN and a LEFT OUTER JOIN. Both versions of the syntax will produce the exact same result in PL/SQL. Some people do recommend including outer in a LEFT JOIN clause so it's clear that you're creating an outer join, but that's entirely optional.
Left Join and Left Outer Join are one and the same. The former is the shorthand for the latter. The same can be said about the Right Join and Right Outer Join relationship. The demonstration will illustrate the equality.
There is no such a thing as a "LEFT INNER JOIN". It's either "LEFT JOIN" or "LEFT OUTER JOIN". "INNER" already means it's the intersection, and the intersection can only be one thing.
To answer your question there is no difference between LEFT JOIN and LEFT OUTER JOIN, they are exactly same that said...
INNER JOIN - fetches data if present in both the tables.
OUTER JOIN are of 3 types:
LEFT OUTER JOIN
- fetches data if present in the left table.RIGHT OUTER JOIN
- fetches data if present in the right table.FULL OUTER JOIN
- fetches data if present in either of the two tables.CROSS JOIN, as the name suggests, does [n X m]
that joins everything to everything.
Similar to scenario where we simply lists the tables for joining (in the FROM
clause of the SELECT
statement), using commas to separate them.
Points to be noted:
JOIN
then by default it is a INNER JOIN
.OUTER
join has to be LEFT
| RIGHT
| FULL
you can not simply say OUTER JOIN
.OUTER
keyword and just say LEFT JOIN
or RIGHT JOIN
or FULL JOIN
.For those who want to visualise these in a better way, please go to this link: A Visual Explanation of SQL Joins
As per the documentation: FROM (Transact-SQL):
<join_type> ::= [ { INNER | { { LEFT | RIGHT | FULL } [ OUTER ] } } [ <join_hint> ] ] JOIN
The keyword OUTER
is marked as optional (enclosed in square brackets). In this specific case, whether you specify OUTER
or not makes no difference. Note that while the other elements of the join clause is also marked as optional, leaving them out will make a difference.
For instance, the entire type-part of the JOIN
clause is optional, in which case the default is INNER
if you just specify JOIN
. In other words, this is legal:
SELECT * FROM A JOIN B ON A.X = B.Y
Here's a list of equivalent syntaxes:
A LEFT JOIN B A LEFT OUTER JOIN B A RIGHT JOIN B A RIGHT OUTER JOIN B A FULL JOIN B A FULL OUTER JOIN B A INNER JOIN B A JOIN B
Also take a look at the answer I left on this other SO question: SQL left join vs multiple tables on FROM line?.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With