From: | Marko Kreen <marko(at)l-t(dot)ee> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Bug: aliasing in ORDER BY when UNIONing |
Date: | 2001-02-19 02:02:37 |
Message-ID: | 20010219040236.A4965@l-t.ee |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Feb 18, 2001 at 08:24:20PM -0500, Tom Lane wrote:
> Marko Kreen <marko(at)l-t(dot)ee> writes:
> > What works:
> > # select o.id from op o union all SELECT -1 order by id;
>
> This is valid SQL.
>
> > # select o.id from op o union all SELECT -1 order by o.id;
> > ERROR: Relation 'o' does not exist
>
> This is not valid SQL. For one thing, the table alias "o" is not
> visible outside the first component SELECT.
>
> Yes, I know 7.0 took it... but its handling of ORDER BY on UNION
> was pretty darn broken.
Doh. But if I have several tables with a field 'id'? Then only
way is to use the column number? But the query is big and composed
of several sources, fields and other stuff is separated - oh
well... Thankfully the field is not 'id' so maybe its not that
bad.
Anyway such stuff should be documented I guess. From current
docs I read that it should work. I would have expected that one
of the select's aliases would be transferred to ORDER BY but its
not possible?
--
marko
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2001-02-19 03:08:21 | Re: PHP 4.0.4pl1 / Beta 5 |
Previous Message | Tatsuo Ishii | 2001-02-19 01:44:43 | Re: [SQL] PL/SQL-to-PL/PgSQL-HOWTO beta Available |