Re: Column "..." does not exist (view + union)

From: Stefan Weiss <krewecherl(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Column "..." does not exist (view + union)
Date: 2011-12-17 14:26:33
Message-ID: 4EECA699.2020700@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 2011-12-17 10:02, Andreas Kretschmer wrote:
> Stefan Weiss <krewecherl(at)gmail(dot)com> wrote:
>>
>> SELECT name
>> FROM dossier_contact_v
>> WHERE dossier_id = 56993
>> AND ctype = 234
>> UNION
>> SELECT name
>> FROM dossier_contact_v
>> WHERE dossier_id = -1
>> AND ctype = -1
>> ORDER BY ctype;
>>
>> - fails with the following error message:
>>
>> ERROR: column "ctype" does not exist
>> LINE 10: ORDER BY ctype;
>
> The reult table doesn't contain a column "ctype", it contains only
> "name". [...]

I see. So this has to do with the union; after combining the two
queries, the tables from the FROM clauses are no longer available.
Thanks, that explains it.

- stefan

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Filip Rembiałkowski 2011-12-17 15:16:07 Re: Natural sort order
Previous Message Richard Klingler 2011-12-17 10:33:06 Natural sort order