Reputation: 239
ID username score
4 | x | 7
7 | y | 3
9 | z | 6
I want to learn y's place at the scoreboard (which is 3.) from MySQL. I could not find the true MySQL query, can you help me?
Upvotes: 1
Views: 116
Reputation: 4957
SELECT * FROM
(SELECT @rank := @rank + 1 AS rank, id,username, score
FROM table , (SELECT @rank := 0) r
ORDER BY score
) k
WHERE k.username = 'y'
Upvotes: 2