tenmiles
tenmiles

Reputation: 2751

Right join vs left join, which table is left vs right?

Given

select * 
from a
left join b
on a.id = b.id

is table a left and table b right?

Would that be equivalent to

Select *
from a
right join b
on b.id = a.id

because I switched left and right while flipping the ON clause? Or is a still left because it came first and b is right because it's the thing we're joining?

Thank you.

Upvotes: 0

Views: 70

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1271141

No. "left" and "right" refer to the ordering of the tables in the FROM clause. So these are equivalent:

select * 
from a left join
     b
     on a.id = b.id

select * 
from b right join
     a
     on a.id = b.id

These two on clauses do exactly the same thing:

on a.id = b.id
on b.id = a.id

They do not affect the results at all.

Upvotes: 2

Related Questions