Re: PostgreSQL 8.0 Beta 4 - Qualified ORDER BY column name not working on UNION query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Scott Eade <seade(at)backstagetech(dot)com(dot)au>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: PostgreSQL 8.0 Beta 4 - Qualified ORDER BY column name not working on UNION query
Date: 2004-10-29 19:22:01
Message-ID: 19602.1099077721@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Scott Eade <seade(at)backstagetech(dot)com(dot)au> writes:
> SELECT TURBINE_USER.USER_ID FROM TURBINE_USER WHERE TURBINE_USER.USER_ID = 1
> UNION
> SELECT TURBINE_USER.USER_ID FROM TURBINE_USER WHERE TURBINE_USER.USER_ID = 2
> -- The following works.
> --ORDER BY 1 ASC
> -- The following does not work when I would perhaps expect it to (it
> certainly works when a non-UNION query is used).
> ORDER BY TURBINE_USER.USER_ID ASC

This isn't a bug. The output columns of the UNION don't belong to any
particular table anymore; they can only be referenced by column number
or unqualified column name.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-10-29 21:06:22 Re: BUG #1301: pg_restore failed on AMD 64bit machine
Previous Message Tom Lane 2004-10-29 19:20:10 Re: copy command PANIC in --encoding='utf8' createdb option