----- Original Message ----- 
From: "Ashley M. Kirchner" <[EMAIL PROTECTED]>
>
>     > SELECT field1,field2,field3 FROM table ORDER BY field3 DESC LIMIT 5;
>     My problem is, I need the last two in that list, in the order
> they're listed there.  If I reverse the order (by using ASC), I will get:
>
>     So, how do I reverse DESC sorting, to get the records in the order
> that I need?

You can cheat a bit and use a UNION of one SELECT:

(SELECT field1,field2,field3 FROM table ORDER BY field3 ASC LIMIT 2) ORDER
BY field3 DESC;

Usually you would use (SELECT ...) UNION (SELECT...) ORDER BY... to sort the
result of the combined queries. MySQL seems to accept the use of only one
SELECT with an implied UNION. I'm not certain how future versions of MySQL
will respond to this variation.

Regards, Jigal.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to