-1

If we can interchange left or right join then what is the use of any specific type of join??

asy
  • 23
  • 2

1 Answers1

0

I think this is actually a good question. I have never heard a really good reason why right join exists. Maybe something from the very old days of SQL required it? It would be really cool is someone had an answer other than appearance.

I like the comment by Gordon.

1 - 1 is the same as 1 + (-1)

To expand on the idea, I have always felt it was for looks. I always use left joins and order the tables in my query to achieve the results I want but could easily use right joins or a mix.

For example

Select a.field, b.field
   From a
   left join b on a.id = b.aid

will return the same results as:

Select a.field, b.field
   From b
   right join a on a.id = b.aid

What it comes down to is that the first table is the left table and the next table is the right table. If you want all the records from a it has to be first in a left join and has to be second in a right join.

Joe C
  • 3,925
  • 2
  • 11
  • 31