DanDaBeginner Posted December 12, 2008 Share Posted December 12, 2008 how can sort the countries by ASC but with USA and Canada being the first.... I guess it will be something like: SELECT * FROM countries ORDER BY (country_name IN ('USA','CANADA')) ASC, country_name DESC.. Thanks in advance... Quote Link to comment https://forums.phpfreaks.com/topic/136618-solved-order-by-statement/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 12, 2008 Share Posted December 12, 2008 Should work - SELECT * FROM countries ORDER BY FIELD(country_name, 'Canada', 'USA') DESC, country_name Ref: http://cakebaker.42dh.com/2008/06/10/order-by-field/ Quote Link to comment https://forums.phpfreaks.com/topic/136618-solved-order-by-statement/#findComment-713345 Share on other sites More sharing options...
xtopolis Posted December 12, 2008 Share Posted December 12, 2008 Nice, I had no idea about this. Quote Link to comment https://forums.phpfreaks.com/topic/136618-solved-order-by-statement/#findComment-713354 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.