MySQL Forums
Forum List  »  Newbie

MYSQL Sorting IN by orignal order?
Posted by: Lawrence Agan
Date: March 06, 2009 05:28AM

I have the following query, which the data within IN is built from PHP. The order is important cause it references miles from and to in order of distance. The problem is I need to get this all into one query. My query works, but it grabs records all over hte place. I would like it to get the data by each zipcode.

SELECT * FROM `autos` WHERE `zip` IN ( 80033, 80034, 80002, 80215, 80001, 80212, 80214, 80225, 80004, 80003, 80226, 80211, 80005, 80204 )

so 80003 vehicle data would come first, then 80034 would be next and so on. Instead of 80226,80005,80003,80005,80005 which is the behavior I get from the query now.

Any ideas? I have tried everything I know, which is not a ton.

Options: ReplyQuote


Subject
Written By
Posted
MYSQL Sorting IN by orignal order?
March 06, 2009 05:28AM


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.