Reputation: 627
I am reading books on outer joins and they reference the "position" of a table in determining whether all of its records will be displayed.
I am confused about how exactly the position (left/right) is determined?
If we consider the standard SQL join
Select * FROM
Table_A left outer join Table_B
on Table_A.ID = Table_B.Product_ID
What part of this query is determining the position of each Table?
Is it the join part:
Table_A left outer join Table_B
Where Table_A is on the "left" because it is left of the join word?
Or is it the "=" part:
on Table_A.ID = Table_B.Product_ID
Where Table_A is on the "left" because it is left of the "=" sign?
Upvotes: 2
Views: 92
Reputation: 8497
This makes the difference, so Table name on left side of LEFT OUTER JOIN
is leading one
Table_A left outer join Table_B
As per the MSDN, left outer joins include all of the records from the first (left) of two tables, even if there are no matching values for records in the second (right) table.
Upvotes: 4
Reputation: 25419
It's the relative position of the table name in the SQL.
table1 left join table2
means table 1 is the principle table, where as in a right join
the table2 would be the principle table.
Upvotes: 0