Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id C18029FBC42 for ; Wed, 13 Jun 2007 10:44:53 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 79802-08 for ; Wed, 13 Jun 2007 10:44:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sd-2317.dedibox.fr (sd-2317.dedibox.fr [88.191.17.192]) by postgresql.org (Postfix) with ESMTP id 9B6069FB6DF for ; Wed, 13 Jun 2007 10:44:47 -0300 (ADT) Received: from sd-2317.dedibox.fr (localhost.localdomain [127.0.0.1]) by sd-2317.dedibox.fr (Postfix) with ESMTP id 79E4DD373; Wed, 13 Jun 2007 15:49:09 +0200 (CEST) Received: from [192.168.10.64] (ASte-Genev-Bois-153-1-30-3.w83-112.abo.wanadoo.fr [83.112.76.3]) by sd-2317.dedibox.fr (Postfix) with ESMTP id 2B09E259A; Wed, 13 Jun 2007 15:49:09 +0200 (CEST) Message-ID: <466FF4C8.3010006@lelarge.info> Date: Wed, 13 Jun 2007 15:44:40 +0200 From: Guillaume Lelarge User-Agent: Thunderbird 2.0.0.0 (X11/20070326) MIME-Version: 1.0 To: "A. R. Van Hook" CC: pgsql-sql@postgresql.org Subject: Re: join problem References: <466FEEC9.4050300@lake-lotawana.mo.us> In-Reply-To: <466FEEC9.4050300@lake-lotawana.mo.us> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.395 tagged_above=0 required=5 tests=AWL=-0.327, BAYES_50=0.001, RCVD_IN_NJABL_PROXY=0.721 X-Spam-Level: X-Archive-Number: 200706/89 X-Sequence-Number: 28579 A. R. Van Hook a écrit : > I have join problem: > "select i.ivid, v.eventdate, v.deposit, v.invdate, cai.db, > sum(i.tax) as tax, > sum(i.tax + i.rowtot) as totalP, > (sum(i.tax + i.rowtot) - v.deposit) as balance > from invoice v > left outer join > invoiceitems i > on v.ivid = i.ivid > where v.cusid = $cusid > and v.cusid = cai.cusid group by > i.ivid, v.eventdate, v.deposit, v.invdate, cai.db > ERROR: missing FROM-clause entry for table "cai" > > If I add cai to the from clause "from invoice v, cai, I get > ERROR: missing FROM-clause entry for table "cai" > ERROR: invalid reference to FROM-clause entry for table "v" > > Where do I add the cai table reference??? > You probably need to change the order of the tables in the FROM clause. Replace FROM invoice v, cai with FROM cai, invoice v Regards. -- Guillaume.