From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: Column "..." does not exist (view + union)
Date: Sat, 17 Dec 2011 10:02:46 +0100
Message-ID: <20111217090246.GA12209@tux> (raw)
In-Reply-To: <4EEC0533.9050007@gmail.com>
References: <4EEC0533.9050007@gmail.com>
Stefan Weiss <krewecherl@gmail.com> wrote:
>
> - running this query -
>
> 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". Rewrite your query to something like:
select name from (select name, ctype from ... union select name, ctype from ...)
foo order by ctype
Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly." (unknown)
Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°
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: akretschmer@spamfence.net
Subject: Re: Column "..." does not exist (view + union)
In-Reply-To: <20111217090246.GA12209@tux>
* 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