X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 081009FB2F3 for ; Thu, 7 Sep 2006 11:30:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 01318-02-4 for ; Thu, 7 Sep 2006 14:30:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mx1.ipf.is (mack.ipf.is [85.197.192.164]) by postgresql.org (Postfix) with ESMTP id C17749FB2FC for ; Thu, 7 Sep 2006 11:29:41 -0300 (ADT) Received: (qmail 22908 invoked by uid 1010); 7 Sep 2006 14:29:31 +0000 Received: from 88.149.106.19 by mack (envelope-from , uid 1008) with qmail-scanner-1.25-st-qms (clamdscan: 0.88.4/1639. spamassassin: 3.1.4. perlscan: 1.25-st-qms. Clear:RC:1(88.149.106.19):SA:0(0.0/4.5):. Processed in 0.339413 secs); 07 Sep 2006 14:29:31 -0000 X-Antivirus-HIVE-Mail-From: gnari@hive.is via mack X-Antivirus-HIVE: 1.25-st-qms (Clear:RC:1(88.149.106.19):SA:0(0.0/4.5):. Processed in 0.339413 secs Process 22900) Received: from dsl-149-106-19.hive.is (HELO ?192.168.1.33?) (88.149.106.19) by mx1.ipf.is with SMTP; 7 Sep 2006 14:29:31 +0000 Subject: Re: Is it possible to left join based on previous joins From: Ragnar To: emilu@encs.concordia.ca Cc: pgsql-sql@postgresql.org In-Reply-To: <45002689.9050307@encs.concordia.ca> References: <45001AF6.4020706@encs.concordia.ca> <45002689.9050307@encs.concordia.ca> Content-Type: text/plain Date: Thu, 07 Sep 2006 14:30:50 +0000 Message-Id: <1157639450.17224.73.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200609/53 X-Sequence-Number: 26264 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 >