Search code examples
sqldatabaseright-join

When or why would you use a right outer join instead of left?


Wikipedia states:

"In practice, explicit right outer joins are rarely used, since they can always be replaced with left outer joins and provide no additional functionality."

Can anyone provide a situation where they have preferred to use the RIGHT notation, and why? I can't think of a reason to ever use it. To me, it wouldn't ever make things more clear.

Edit: I'm an Oracle veteran making the New Year's Resolution to wean myself from the (+) syntax. I want to do it right


Solution

  • The only reason I can think of to use RIGHT OUTER JOIN is to try to make your SQL more self-documenting.

    You might possibly want to use left joins for queries that have null rows in the dependent (many) side of one-to-many relationships and right joins on those queries that generate null rows in the independent side.

    This can also occur in generated code or if a shop's coding requirements specify the order of declaration of tables in the FROM clause.