Fraser Murrell wrote:
> Felix - Thank you, not entirely sure what it means, but it works great!
The query was:
SELECT category, title, pubdate
FROM ds
WHERE category IN (2, 5, 4, 101, 7)
ORDER BY CASE category
WHEN 3 THEN 10
WHEN 5 THEN 20
WHEN 4 THEN 30
WHEN 101 THEN 40
WHEN 7 THEN 50
ELSE 999
END
An 'ORDER BY something' clause sorts your records according to the value of 'something' for each record (standard from low to high).
In this case, something is a CASE ... END construct
(see
http://dev.mysql.com/doc/mysql/en/case-statement.html)
This CASE ... END construct translates your category values into numbers (the 10 ... 50, 999) that provide the correct numbers for the wanted sorting.
--
felix
Please use
BBCode to format your messages in this forum.