On Nov 30, 2008, at 11:42 PM, Andy Shellam wrote:
Hi Morten,
I think this is valid in MySQL (it certainly is for SQL Server) but
you can use a CASE statement directly in the ORDER BY clause. Try
something like this:
SELECT name
FROM foo
WHERE bar = 34
OR baz > 100
ORDER BY CASE bar WHEN 34 THEN 0 ELSE 1 END ASC, baz DESC
LIMIT 5;
Indeed! Thanks! I also found that I can simplify it a little by
replacing CASE .. END with IF(condition, 0, 1).
Morten
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]