Home > other >  What is the left and right table for joins after the first join in SQL(postgresql?
What is the left and right table for joins after the first join in SQL(postgresql?

Time:01-21

I want to know, what constitutes as the left table and the right table after the first join.

For example:

From final_productions fp
             left join things.pc p on fp.production_id = p.id
             left join events.time t on fp.tx_id = t.id
             left join things.car c on c.id = fp.channel_id
             right join events.form f on f.production_id = p.id
             left join events.trigger_alert ta on mc.cue_sheet_id = ta.id

I know for the first left join inner join things.pc p on fp.production_id = p.id the left table would be the table in the from statement which is final_productions. But what about the other joins(i.e the joins after the first join statement)? Could someone explain this, please? Thanks

CodePudding user response:

The documentation says:

Parentheses can be used around JOIN clauses to control the join order. In the absence of parentheses, JOIN clauses nest left-to-right.

So

a LEFT JOIN b RIGHT JOIN c

is the same as

(a LEFT JOIN b) RIGHT JOIN c
  •  Tags:  
  • Related