mysql get order number
list, mysql, ranking
Solution
Try doing:
select * from (
select @rownum: = @rownum + 1 Num,
Country,
UserId,
points
from users, (select @rownum: = 0) r
where country = 840
order by points desc
) a
where userId = 23
Problem
I have the following structure Country - UserId - Points 840 23 24 840 32 31 840 22 38 840 15 35 840 10 20 250 15 33 724 17 12 etc I want to get the position of user in the ranking of each country accordin points I'm using ``` select @rownum:=@rownum+1 Num, Country, UserId, points from users , (SELECT @rownum:=0) r where country=840 order by points DESC ; ``` I want to get the position of a single user inside his country In this example, in country 840, if I select user id=23, I'll get position 4 Country - UserId - Points- Order 840 22 38 1 840 15 35 2 840 32 31 3 840 23 24 4 840 10 20 5