MySQL Forums
Forum List  »  Newbie

Re: reversed limit
Posted by: Ramalingam Chelliah
Date: August 25, 2004 06:54AM

Hi ,
Check Whether the first User comment in this Manual Page helps you..

User Comments
Posted by Keith Ivey on May 8 2003 1:10pm [Delete] [Edit]

It's not documented above, but you can use ORDER BY on a UNION that consists of only one SELECT (and thus doesn't actually include the word "UNION"). Suppose you want the last 5 entries in a table, but you want them in ascending order. You can use this query:

( SELECT * FROM table_name ORDER BY ranking DESC
LIMIT 5 ) ORDER BY ranking;

Similarly, you could select the top 10 records from a table ordered by one column and then sort them alphabetically by another column.


Hope this helps you ....


We Learn the Most When we have to Invent

Options: ReplyQuote

Written By
August 25, 2004 06:16AM
Re: reversed limit
August 25, 2004 06:54AM
August 25, 2004 07:07AM

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.