JSONB
JSONB

Reputation: 31

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

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

Upvotes: 0

Views: 45

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246433

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

Upvotes: 1

Related Questions