sean14592 Posted January 22, 2009 Share Posted January 22, 2009 Hello. How do I do a mysql query to return the top 10 results ordered by points. For example my database looks like this: User | Points 1 | 10 2 | 45 3 | 0 4 | 10 5 | 45 6 | 0 7 | 10 8 | 45 9 | 0 So i basically want a leaderboard showing the top 10 users. Cheers Sean Quote Link to comment https://forums.phpfreaks.com/topic/141944-solved-top-10-mysql-query/ Share on other sites More sharing options...
sean14592 Posted January 22, 2009 Author Share Posted January 22, 2009 anyone? I thought this would eb an easy fix, but I can't find anything anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/141944-solved-top-10-mysql-query/#findComment-743701 Share on other sites More sharing options...
elflacodepr Posted January 22, 2009 Share Posted January 22, 2009 You may use the LIMIT() command which you will tell to DB how many results you want to show: LIMIT(0, 10) and to order from highest rating to lowest use: ORDER BY 'Points' DESC Quote Link to comment https://forums.phpfreaks.com/topic/141944-solved-top-10-mysql-query/#findComment-743712 Share on other sites More sharing options...
sean14592 Posted January 22, 2009 Author Share Posted January 22, 2009 ok, nice, which one should I do first, order it then limit? sean Quote Link to comment https://forums.phpfreaks.com/topic/141944-solved-top-10-mysql-query/#findComment-743718 Share on other sites More sharing options...
trq Posted January 22, 2009 Share Posted January 22, 2009 SELECT user FROM tbl ORDER BY points DESC LIMIT 10; Quote Link to comment https://forums.phpfreaks.com/topic/141944-solved-top-10-mysql-query/#findComment-743733 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.