johnsmith153 Posted January 24, 2011 Share Posted January 24, 2011 "ORDER BY field" would return 1, 2 3 in that order However I want it to return 3, 1, 2 (there are actually no other possible responses) How would I do this? Link to comment https://forums.phpfreaks.com/topic/225571-ultra-simple-order-by/ Share on other sites More sharing options...
johnny86 Posted January 24, 2011 Share Posted January 24, 2011 ORDER BY field DESC Link to comment https://forums.phpfreaks.com/topic/225571-ultra-simple-order-by/#findComment-1164756 Share on other sites More sharing options...
btherl Posted January 24, 2011 Share Posted January 24, 2011 There's a few ways to do that. ORDER by field = 3 DESC, field That should do it. Or ORDER BY CASE WHEN field = 3 THEN 0 ELSE field END Or you could order by "field mod 3", which will map 3 to 0 and leave 1 and 2 unchanged. Link to comment https://forums.phpfreaks.com/topic/225571-ultra-simple-order-by/#findComment-1164757 Share on other sites More sharing options...
johnsmith153 Posted January 24, 2011 Author Share Posted January 24, 2011 Great, thanks btherl Link to comment https://forums.phpfreaks.com/topic/225571-ultra-simple-order-by/#findComment-1164773 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.