pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guillaume Lelarge <guillaume@lelarge.info>
To: A. R. Van Hook <hook@lake-lotawana.mo.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: join problem
Date: Wed, 13 Jun 2007 15:44:40 +0200
Message-ID: <466FF4C8.3010006@lelarge.info> (raw)
In-Reply-To: <466FEEC9.4050300@lake-lotawana.mo.us>
References: <466FEEC9.4050300@lake-lotawana.mo.us>

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.
<!-- http://abs.traduc.org/
     http://lfs.traduc.org/
     http://docs.postgresqlfr.org/ -->



view thread (12+ messages)  latest in thread

Message-ID: <466FF4C8.3010006@lelarge.info>
Permalink:  ../466FF4C8.3010006@lelarge.info/
Also on:    postgresql.org/message-id/466FF4C8.3010006@lelarge.info

 · 

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: guillaume@lelarge.info, hook@lake-lotawana.mo.us
  Subject: Re: join problem
  In-Reply-To: <466FF4C8.3010006@lelarge.info>

* 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