I have a USER
table, that has userId
and point
fields. At runtime, I want to know what is a ranking of a particular user base on their point. What is the best way to accomplish this:
I expect 2000-5000 users.
SET @rownum := 0;
SELECT rank, userId, point
FROM (
SELECT @rownum := @rownum + 1 AS rank, userId, point
FROM user ORDER BY point DESC
)
as result WHERE userId = xxxxxxxx
精彩评论