开发者

MySQL & PHP leaderboard query

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜