0

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.

tenmiles
  • 2,521
  • 3
  • 18
  • 20
  • Before considering posting please read the manual & google any error message or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names & site:stackoverflow.com & tags; read many answers. If you post a question, use one phrasing as title. Reflect your research. See [ask] & the voting arrow mouseover texts. Please don't ask or answer duplicate questions. – philipxy Apr 15 '20 at 23:41
  • Does this answer your question? [Which table exactly is the "left" table and "right" table in a JOIN statement (SQL)?](https://stackoverflow.com/questions/4109704/which-table-exactly-is-the-left-table-and-right-table-in-a-join-statement-s) – philipxy Apr 15 '20 at 23:42

1 Answers1

2

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.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786