Kryptix Posted December 17, 2009 Share Posted December 17, 2009 How would I order a SELECT by one column followed by another and another? So for example, I want to order them by their name first, then their age and then their DoB. I tried ORDER BY `name`, `age`, `DoB` but it doesn't give the results I'm expecting. Am I doing it right? Also, can you make say the name DESC, and then the age ASC separately? Quote Link to comment https://forums.phpfreaks.com/topic/185425-order-by-more-than-one/ Share on other sites More sharing options...
ngreenwood6 Posted December 17, 2009 Share Posted December 17, 2009 should be: $query = "SELECT * FROM table WHERE something='something' ORDER BY name DESC, age ASC"; Quote Link to comment https://forums.phpfreaks.com/topic/185425-order-by-more-than-one/#findComment-978873 Share on other sites More sharing options...
Kryptix Posted December 17, 2009 Author Share Posted December 17, 2009 Nice one, I was messing around with it and it clocked on just before you replied. Quote Link to comment https://forums.phpfreaks.com/topic/185425-order-by-more-than-one/#findComment-978883 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.