The following query will give you a new UserRank column that sets the user rank:
SELECT UserID, Score, (@rownum := @rownum + 1) UserRank FROM table_score, (SELECT @rownum := 0) t ORDER BY Score DESC;
SQL Fiddle Demo
This will give you something like:
| USERID | SCORE | USERRANK | ----------------------------- | 4 | 100 | 1 | | 10 | 70 | 2 | | 2 | 55 | 3 | | 1234 | 50 | 4 | | 1 | 36 | 5 | | 20 | 33 | 6 | | 8 | 25 | 7 |
You can then put this query in a subquery and filter using userId to get this user rating. Sort of:
SELECT t.UserRank FROM ( SELECT *, (@rownum := @rownum + 1) UserRank FROM table_score, (SELECT @rownum := 0) t ORDER BY Score DESC ) t WHERE userID = '1234';
SQL Fiddle Demo
source share