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?
I know that this is old however wanted to put my two cents in. I understand that the
LEFT JOIN
should be the same asLEFT OUTER JOIN
but in my experience I have seen aLEFT JOIN
pull back different Results than aLEFT OUTER JOIN
so I have started to use the key wordOUTER
to be more specific and proper. Rows that should have come back in aLEFT JOIN
did not where as when I would use aLEFT OUTER JOIN
it did. I was trying to explain this to a colleague when he was unable to get the rows that he needed as well so I decided to Google the difference so as to have some sort of backing to show him. This might be a SQL Server specific thing to which I am uncertain about. I would say that in good practice it would be more advisable to explicitly state that you want an outer join to occur. Just my opinion.According to DoFactory
At the top level there are mainly 3 types of joins:
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 theSELECT
statement), using commas to separate them.Points to be noted:
JOIN
then by default it is aINNER JOIN
.OUTER
join has to beLEFT
|RIGHT
|FULL
you can not simply sayOUTER JOIN
.OUTER
keyword and just sayLEFT JOIN
orRIGHT JOIN
orFULL JOIN
.For those who want to visualise these in a better way, please go to this link: A Visual Explanation of SQL Joins
I'm a PostgreSQL DBA, as far as I could understand the difference between outer or not outer joins difference is a topic that has considerable discussion all around the internet. Until today I never saw a difference between those two; So I went further and I try to find the difference between those. At the end I read the whole documentation about it and I found the answer for this,
So if you look on documentation (at least in PostgreSQL) you can find this phrase:
"The words
INNER
andOUTER
are optional in all forms.INNER
is the default;LEFT
,RIGHT
, andFULL
imply an outer join."In another words,
LEFT JOIN
andLEFT OUTER JOIN
ARE THE SAMERIGHT JOIN
andRIGHT OUTER JOIN
ARE THE SAMEI hope it can be a contribute for those who are still trying to find the answer.
Nothing to say in words beside this:
To answer your question
It is mentioned in msdn article : https://msdn.microsoft.com/en-us/library/ms177634(v=sql.130).aspx
So following list shows join equivalent syntaxes with and without OUTER
Other equivalent syntaxes
Strongly Recommend Dotnet Mob Artice : Joins in Sql Server