0

I think either left/right join is sufficient, the other will derived if table names are interchanged, Anyone know why there is both left and right join? Thanks

Akilan
  • 41
  • 4

1 Answers1

1

The order of join evaluation is generally left-to-right. So a join b join c executes as if you had parenthesized it (a join b) join c.

The optimizer can reorder inner joins because inner joins are commutative. Reordering outer joins is not commutative (i.e. a left join b is not the same as b left join a), so the optimizer can't swap them.

If you want to do a left outer join to the result of a joined pair of tables, use parentheses, like: a left join (b join c).

But you can also take advantage of the left-to-right order of evaluation by switching to a right outer join: b join c right outer join a -- without parentheses!

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828