xXREDXIIIXx Posted March 8, 2011 Share Posted March 8, 2011 basically i have a quiz leader board cols: username, time, correct I want to first order by correct answers DESC but also by fastest times DESC. example: (time / correct) 300 / 50 299 / 50 200 / 50 280 / 49 270 / 49 350 / 48 any help would be great. Quote Link to comment https://forums.phpfreaks.com/topic/230042-order-by-2-things/ Share on other sites More sharing options...
Pikachu2000 Posted March 8, 2011 Share Posted March 8, 2011 Where are you stuck, exactly? Quote Link to comment https://forums.phpfreaks.com/topic/230042-order-by-2-things/#findComment-1184782 Share on other sites More sharing options...
xXREDXIIIXx Posted March 8, 2011 Author Share Posted March 8, 2011 to be honest with you I just don't know where to begin I'm actively googling now for hints etc Quote Link to comment https://forums.phpfreaks.com/topic/230042-order-by-2-things/#findComment-1184785 Share on other sites More sharing options...
Maq Posted March 8, 2011 Share Posted March 8, 2011 Please refer to the manual: http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html As you can see by the examples, you can easily ORDER BY two columns separating them by commas. Quote Link to comment https://forums.phpfreaks.com/topic/230042-order-by-2-things/#findComment-1184787 Share on other sites More sharing options...
xXREDXIIIXx Posted March 8, 2011 Author Share Posted March 8, 2011 Maq, your a saint, SELECT * FROM t1 ORDER BY key_part1 DESC, key_part2 DESC; Works like a dream. Love you guys Bookmarked mysql.com Quote Link to comment https://forums.phpfreaks.com/topic/230042-order-by-2-things/#findComment-1184792 Share on other sites More sharing options...
Maq Posted March 8, 2011 Share Posted March 8, 2011 Maq, your a saint, Far from one, but thanks > Quote Link to comment https://forums.phpfreaks.com/topic/230042-order-by-2-things/#findComment-1184794 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.