What is the difference between LEFT JOIN
and LEFT OUTER JOIN
?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- How to truncate seconds in TSQL?
- Code for inserting data into SQL Server database u
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
- Is recursion good in SQL Server?
There are only 3 joins:
C) Outer join:
Hope it'd help.
As per the documentation: FROM (Transact-SQL):
The keyword
OUTER
is marked as optional (enclosed in square brackets), and what this means in this case is that whether you specify it or not makes no difference. Note that while the other elements of the join clause is also marked as optional, leaving them out will of course make a difference.For instance, the entire type-part of the
JOIN
clause is optional, in which case the default isINNER
if you just specifyJOIN
. In other words, this is legal:Here's a list of equivalent syntaxes:
Also take a look at the answer I left on this other SO question: SQL left join vs multiple tables on FROM line?.
Left Join
andLeft Outer Join
are one and the same. The former is the shorthand for the latter. The same can be said about theRight Join
andRight Outer Join
relationship. The demonstration will illustrate the equality. Working examples of each query have been provided via SQL Fiddle. This tool will allow for hands on manipulation of the query.Given
Left Join and Left Outer Join
Results
Right Join and Right Outer Join
Results
As its already mentioned here, there is NO difference. The key world
OUTER
could be removed from SQL keyword dictionary without we losing expressional power on the queries we are able to write.Also, we do not need both
RIGHT
andLEFT
keywords as only one of them is sufficient. This is becauseSELECT * FROM A RIGHT JOIN B on A.ID = B.ID
is exactly same asSELECT * FROM B LEFT JOIN A on A.ID = B.ID
. I have found all these extra terms confusing students and novice people.I find it easier to think of Joins in the following order:
Until I figured out this (relatively) simple model, JOINS were always a bit more of a black art. Now they make perfect sense.
Hope this helps more than it confuses.
Nothing.
LEFT JOIN
andLEFT OUTER JOIN
are equivalent.