Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 3AF519FB21D for ; Wed, 29 Nov 2006 20:57:24 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 22782-04 for ; Wed, 29 Nov 2006 20:57:09 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web31815.mail.mud.yahoo.com (web31815.mail.mud.yahoo.com [68.142.206.168]) by postgresql.org (Postfix) with SMTP id BDA549FB1CF for ; Wed, 29 Nov 2006 20:57:19 -0400 (AST) Received: (qmail 23126 invoked by uid 60001); 30 Nov 2006 00:57:18 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=0c4uWq77WTWge80Mhozh/wfaUMEXQIWwC+yYcCfb4tZjqdatHw4spUB7kbQlI5r5YkAe3+WuqqqSDH04MvCDSl/mGDP4+x/6U+4wxkpe9KbCeyqzaZkXW68+Gu4p8PVIrPBtkjDYH48L+HColBu25UzmiI5Us4rl/jGCoBsWUZs=; X-YMail-OSG: 62GG9gYVM1lAigFOmHkg5HbVpVrLDDPKpLUQx40iLNlpoz_K78uAVssXgGGcd73YwP76rkjD.cmGMQXaE1W9mH_c9UmN0z4XALc1eDMduo61uxutNaf8PjItiQ3wJHdUshxrygqTON6BuF0- Received: from [24.54.196.198] by web31815.mail.mud.yahoo.com via HTTP; Wed, 29 Nov 2006 16:57:18 PST Date: Wed, 29 Nov 2006 16:57:18 -0800 (PST) From: Richard Broersma Jr Subject: Re: SQL command join question To: Ehab Galal , pgsql-sql@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <458025.22989.qm@web31815.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL, BAYES_00, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: X-Archive-Number: 200611/284 X-Sequence-Number: 26936 > SELECT t1.* > FROM (t1 outer join t2 on (t1.a=t2.a and t1.b=t2.b)) t outer join t3 on ^^ > (t1.c=t3.c); ^^ -- which one t or t1? > I'm getting the following error message: > ERROR: invalid reference to FROM-clause entry for table "t1" > HINT: There is an entry for table "t1", but it cannot be referenced from > this part of the query. I am not use if I am about to give to the correct advice, but here is what stands out at me: when you specify an outer join, I believe that you have to specify whether it is a (left|right|full). Also you are using a "t" to alias the (t1 .. t2 on (...)). First of all, I am not sure this is good syntax, but if I am wrong I will have learned something new. That aside, if it is legal syntax, I don't believe that you can refer to any of it's enternal tables any more. So (t1.c=...) should really be (t.c=...). this is what I expect would work: select * from t1 left outer join t2 on ((t1.a,t1.b) = (t2.a,t2.b)) left outer join t3 on (t1.c = t3.c) ; Regards, Richard Broersma Jr.