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