开发者

MySQL & PHP leaderboard query

开发者 https://www.devze.com 2023-04-09 20:55 出处:网络
I have a set of players and I want to select the top 5 scores 开发者_Python百科from the tables and print out the username and scores in descending order, what\'s the SQL statement for that?

I have a set of players and I want to select the top 5 scores 开发者_Python百科from the tables and print out the username and scores in descending order, what's the SQL statement for that? and How to output the result?


SELECT * FROM yourtable ORDER BY score DESC LIMIT 5

Explanations:

SELECT * FROM yourtable: we select yourtable.

ORDER BY score DESC: We order the results based on the column score and in descending order.

LIMIT 5: we limit the number of results by 5.

0

精彩评论

暂无评论...
验证码 换一张
取 消