MySQL Forums
Forum List  »  Newbie

Re: No Sort Order?
Posted by: Felix Geerinckx
Date: May 24, 2005 03:24PM

Fraser Murrell wrote:

> SELECT category, title, pubdate
> FROM ds
> WHERE category = 3 OR category = 5 OR category = 4 OR
> category = 101 OR category = 7
>
> I want the result set to return the results in the order that I have queried above (ie: 3,5,4,101,7)

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

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
May 24, 2005 02:48PM
Re: No Sort Order?
May 24, 2005 03:24PM
May 25, 2005 01:56AM
May 25, 2005 02:41AM


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.