On 22 Apr 2004 at 12:31, Johan Hook wrote: > Assuming you want to order your arbitrary selection you could > do something like: > (SELECT t.Id FROM tab t LIMIT 10) > UNION ALL > (SELECT t.Id FROM tab t WHERE 1 < 0) > ORDER BY t.Id
You don't even need to include the dummy query. You can do a UNION of one result set. This should work: (SELECT t.Id FROM tab t LIMIT 10) ORDER BY t.Id I wrote this comment on the mysql.com site: 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. Now, the fact that the syntax isn't documented may mean that it will disappear, but it's reasonable and useful. -- Keith C. Ivey <[EMAIL PROTECTED]> Tobacco Documents Online http://tobaccodocuments.org -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]