From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>, PostgreSQL-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: UNION problem |
Date: | 2003-02-04 09:56:54 |
Message-ID: | 200302040956.55607.dev@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tuesday 04 Feb 2003 6:08 am, Jean-Christian Imbeault wrote:
> I have the following two separate QL queires which work fine alone. But
> if I tried and UNION them I get an error which doesn't seem to make
> sense, "Attribute not found ...". Can someone spot and point out out my
> mistake/error?
> TAL=# SELECT prod_id FROM invoice_li, products, movies WHERE
> prod_id=products.id AND movies.id=products.id AND received AND ship_now
> AND not cancelled AND invoice_id not in (select id from invoices where
> cancelled) UNION SELECT prod_id FROM invoice_li, products, movies WHERE
> invoice_id not in (select invoice_id from invoice_li where cancelled OR
> not received OR shipped) AND prod_id=products.id AND
> movies.id=products.id AND received AND ship_now AND not cancelled GROUP
> BY prod_id, prod_type_id, maker_id, maker_prod_code, label_id ORDER BY
> prod_type_id, maker_id, maker_prod_code, label_id
> TAL-# ;
> ERROR: Attribute "prod_type_id" not found
Since the two queries work separately, I'd guess PG is trying to locate
prod_type_id via a different route when unioned. What happens if you qualify
all the column-names?
Something like:
select min(f.a) from foo f group by f.b UNION select min(f2.a) FROM foo f2
group by f2.b;
--
Richard Huxton
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Haworth | 2003-02-04 11:00:24 | Re: DBI driver and transactions |
Previous Message | Vicente Alabau Gonzalvo | 2003-02-04 08:51:29 | Re: Comparing different numeric data types |