jaymc Posted May 26, 2009 Share Posted May 26, 2009 Lets say I have a field which contains the following entries, as enum for example Beans Lettuce Chocolate Onion Milk I want to order by Beans, Milk, Onion, Chocolate, Lettuce So not ASC or DESC, an order which is defined by data I input as shown above Quote Link to comment https://forums.phpfreaks.com/topic/159746-solved-order-by-data/ Share on other sites More sharing options...
Maq Posted May 26, 2009 Share Posted May 26, 2009 SELECT * FROM table ORDER BY FIELD(field_name, 'Beans', 'Lettuce', 'Chocolate', 'Onion', 'Milk') DESC; Quote Link to comment https://forums.phpfreaks.com/topic/159746-solved-order-by-data/#findComment-842569 Share on other sites More sharing options...
jaymc Posted May 26, 2009 Author Share Posted May 26, 2009 Hmm that didn't appear to work. It just orders the data by DESC ignoring my defined order Heres the query SELECT `First Name`, `Mobile Phone`, `ID/Status` idstat FROM `example_innodb` GROUP BY `Mobile Phone` ORDER BY FIELD(`ID/Status`, 'Hot Prospect', 'Prospect', 'Be Back', 'Blow Out') DESC Quote Link to comment https://forums.phpfreaks.com/topic/159746-solved-order-by-data/#findComment-842589 Share on other sites More sharing options...
Maq Posted May 26, 2009 Share Posted May 26, 2009 Take out DESC. Quote Link to comment https://forums.phpfreaks.com/topic/159746-solved-order-by-data/#findComment-842595 Share on other sites More sharing options...
jaymc Posted May 26, 2009 Author Share Posted May 26, 2009 Worked Quote Link to comment https://forums.phpfreaks.com/topic/159746-solved-order-by-data/#findComment-842656 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.