inner-joinouter-joincross-join

What's the difference between Cross Join, Inner Join, and Left Outer Join?


If an INNER JOIN can be thought of as a CROSS JOIN and then getting the records that satisfy the condition, then a LEFT OUTER JOIN can be thought of as that plus ONE record of the left table that doesn't satisfy the condition.

It is not a CROSS JOIN that goes easy on the left records (even when the condition is not satisfied), because then a left record can appear as many times as there are records in the right table.

What is wrong with my reasoning that LEFT OUTER JOIN is CROSS JOIN WHERE the records satisfy the condition plus ONE record from the LEFT TABLE that doesn't satisfy the condition?


Solution

  • I don't think it is correct to say a left outer join is: "the cross join with the records satsifying the condition and one record for the left table that doesn't satisy the condition".

    An inner join without a condition is the same as a cross join. An inner join on x is the same as a cross join where x. But prefer the first as it is more explicit and harder to get wrong.

    However with an outer join you don't always get the row "that doesn't satisfy the condition". The difference between a left outer join and an inner join is:

    You don't get both the rows that match and one row that doesn't - you either get the first situation or the second. Your statement seems to suggest that you can get both.