Re: missing FROM-clause notice but nothing is missing ...

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: missing FROM-clause notice but nothing is missing ...
Date: 2003-03-28 05:27:23
Message-ID: 20030327212453.S87976-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Fri, 28 Mar 2003, Jean-Christian Imbeault wrote:

> I get a "missing FROM-clause" with the following query. I don't see why
> as prod_id is a FK in the supposedly missing table ...
>
> I also get an error on my ORDER by, even though I am ordering on
> products.id which is what both selects retrieve ...
>
> This looks like a simple thing but I cannot figure out what I missed ....
>
> DB=# SELECT products.id
> FROM products
> WHERE name ILIKE 'AA'
>
> UNION
>
> SELECT prod_id
> FROM rel_cast_crew_movies
> WHERE cast_crew_id=1012
> ORDER BY products.id;
>
> NOTICE: Adding missing FROM-clause entry for table "products"
> ERROR: ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of
> the result columns

I think this is because by the time you get to the order by, products and
rel_cast_crew_movies are treated as being out of scope. The column
produced by the union is just named "id" I think.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Christian Imbeault 2003-03-28 05:28:48 Re: missing FROM-clause notice but nothing is missing ...
Previous Message Jean-Christian Imbeault 2003-03-28 04:58:52 Re: missing FROM-clause notice but nothing is missing ...