MySQL Forums
Forum List  »  Newbie

Query result - not to be sorted asc or desc
Posted by: Klaus Posenauer
Date: July 24, 2005 05:50AM

Hi - I'm a total newbie on MySQL
I have set up a database about locations and need to have the query result listed in the order of the query itself

Example

select l.notes from locations l where l.location = d or l.location = a or l.location = c or l.location = b
order by l.location = b , l.location = c, l.location = a, l.location = d

Which gives me the output in following order
d
a
c
b

That is the way I actually need the result. But above method seems very tedious to me in particular when we talk about 30 - 40 different locations.
Is there a different (shorter) way to achieve the same result (without having to go through the order by
location bits in reverse order)?

Any help would be appreciated.

Options: ReplyQuote


Subject
Written By
Posted
Query result - not to be sorted asc or desc
July 24, 2005 05:50AM


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.