Re: Is it possible to left join based on previous joins result

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Is it possible to left join based on previous joins result
Date: 2006-09-07 14:26:33
Message-ID: 20060907072131.J60412@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 7 Sep 2006, Emi Lu wrote:

> Hello,
>
> Is it possible to do something like:
>
> select ...
> from t1
> inner join t2 ...
> left join t2.colN
>
> When t1 inner join with t2 I got unique result for t2.colN( colN's value
> is table name).
>
> Can I continue to left join with the column "colN" in table t2?

No, in part because it'd have to actually evaluate the first join in order
to even plan the remainder of the query. It might be possible to do
something similar, albeit somewhat slowly, inside a set returning
function, but you'd have to decide how to handle more than one row being
returned from the first join even if the value is unique, is that one join
against the table or multiple joins.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ragnar 2006-09-07 14:30:50 Re: Is it possible to left join based on previous joins
Previous Message Stephan Szabo 2006-09-07 14:20:27 Re: Problem with FOR UPDATE