pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ragnar <gnari@hive.is>
To: emilu@encs.concordia.ca
Cc: pgsql-sql@postgresql.org
Subject: Re: Is it possible to left join based on previous joins
Date: Thu, 07 Sep 2006 14:30:50 +0000
Message-ID: <1157639450.17224.73.camel@localhost.localdomain> (raw)
In-Reply-To: <45002689.9050307@encs.concordia.ca>
References: <45001AF6.4020706@encs.concordia.ca>
	<45002689.9050307@encs.concordia.ca>

On fim, 2006-09-07 at 10:02 -0400, Emi Lu wrote:
> I tried the example as the following:
> 
> create table a(col1);
> create table b(col1, col2)
> 
> select a.*
> from a inner join b using(col2)
> left join b.col2 as c on (c.col1 = a.col1)
> 
> System notifies me that b is not a schema name.
> 
> So, I guess the approach that I tried to do is not acceptable by Pgsql 
> grammar.

it seems to me that basically you want to
select from a table whose name is stored in another
table.

one way to do that would be to use plpgsql or
some other procedural language to create
a set returning function, so that you
could do:
SELECT * from selfromtab('sometable');

after that is done,you might be able to use that
in joins

gnari







> 
> 
> > 
> > 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?
> > 
> > Thanks
> > 
> > 
> > 
> > 
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Have you searched our list archives?
> > 
> >               http://archives.postgresql.org
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
> 




view thread (5+ messages)  latest in thread

Message-ID: <1157639450.17224.73.camel@localhost.localdomain>
Permalink:  ../1157639450.17224.73.camel@localhost.localdomain/
Also on:    postgresql.org/message-id/1157639450.17224.73.camel@localhost.localdomain

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gnari@hive.is, emilu@encs.concordia.ca
  Subject: Re: Is it possible to left join based on previous joins
  In-Reply-To: <1157639450.17224.73.camel@localhost.localdomain>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox