Re: LEFT and RIGHT JOIN

From: Misa Simic <misa(dot)simic(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: LEFT and RIGHT JOIN
Date: 2012-06-29 22:20:57
Message-ID: CAH3i69=JMhSnPmcWgnP_xeub=2PQNqKTNCwUk0Rqzn2AAw76Wg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks Tom,

Yes you are right... I wanted: t1 left join (t2 inner join t3)
Is there a way to "say" that? I mean to me, it is logical and without
brackets... i.e. t1 left join t2 inner join t3 left join t4, I would read
as: t1 left join (t2 inner join t3) left join t4 .... (Like INNER has
advantage on OUTER...)...

(But I believe my logic is wrong - because of I have tried that on
different SQL engines...)

Or the only way to "say" that is to dont care is there INNER or not... Just
put brackets (in head) from left to right in row how table shows in line
and if you want SELECT all from 1 table make sure it is on the end of the
line (in that case you will need to use RIGHT of course)?

Thanks,

Misa

2012/6/29 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>

> Perhaps you're confused about the syntactic binding of JOINs?
> The first query is (t1 left join t2) inner join t3, while the last one
> is (t3 inner join t2) right join t1, which is the same as
> t1 left join (t2 inner join t3), which is not typically the same
> thing as the first one, because inner joins don't associate in or out
> of the nullable side of an outer join.
>
> regards, tom lane
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-06-29 22:36:52 Re: LEFT and RIGHT JOIN
Previous Message Ben Chobot 2012-06-29 22:12:12 Re: Promotion of standby to master