MySQL Forums
Forum List  »  General

Re: UNION is ruining my ORDER BY!
Posted by: Felix Geerinckx
Date: May 10, 2005 01:23PM

Kim Pedersen wrote:

> If I have a "select Bla moreBla order by bla" , sorting is nice
> if I then make a union
> (select bla morebla from blaTable order by Bla)
> union
> (Select damn moredamn from DamnTable )
>
> the sorting goes wrong - even if the "Select damn .." return 0 records

In http://dev.mysql.com/doc/mysql/en/union.html, one can read:

ORDER BY for individual SELECT statements within parentheses only has an effect when combined with LIMIT. Otherwise, the ORDER BY is optimized away.

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
Re: UNION is ruining my ORDER BY!
May 10, 2005 01:23PM
May 10, 2005 10:00PM
May 11, 2005 02:26AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.