erme Posted February 26, 2010 Share Posted February 26, 2010 How can I do something like this? ORDER BY FieldName (name1,name2,name3) Where name1,name2 etc is actual inputs in FieldName Link to comment https://forums.phpfreaks.com/topic/193451-order-by-inputs/ Share on other sites More sharing options...
trq Posted February 26, 2010 Share Posted February 26, 2010 Sorry, that doesn't make allot of sense. Can you be a little more descriptive? Link to comment https://forums.phpfreaks.com/topic/193451-order-by-inputs/#findComment-1018452 Share on other sites More sharing options...
erme Posted February 26, 2010 Author Share Posted February 26, 2010 Sorry, that doesn't make allot of sense. Can you be a little more descriptive? I have a table with some values inside: ID | Location 1 | Berlin 2 | Berlin 3 | London 4 | New York 5 | LA I want to order by "New York" so the first result would be New York followed by the rest. Link to comment https://forums.phpfreaks.com/topic/193451-order-by-inputs/#findComment-1018457 Share on other sites More sharing options...
trq Posted February 26, 2010 Share Posted February 26, 2010 SELECT ID, Location FROM tbl ORDER BY(Location, 'New York'); Link to comment https://forums.phpfreaks.com/topic/193451-order-by-inputs/#findComment-1018468 Share on other sites More sharing options...
erme Posted February 26, 2010 Author Share Posted February 26, 2010 Hmm, doesn't seem to work Link to comment https://forums.phpfreaks.com/topic/193451-order-by-inputs/#findComment-1018546 Share on other sites More sharing options...
fenway Posted February 26, 2010 Share Posted February 26, 2010 I think thorpe meant: SELECT ID, Location FROM tbl ORDER BY FIELD(Location, 'New York'); But careful if there are non-matching value. Link to comment https://forums.phpfreaks.com/topic/193451-order-by-inputs/#findComment-1018589 Share on other sites More sharing options...
erme Posted February 26, 2010 Author Share Posted February 26, 2010 Perfect! Thank's guys. Link to comment https://forums.phpfreaks.com/topic/193451-order-by-inputs/#findComment-1018613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.