# MySQL query, PHP help

**URL:** <https://forum.kirupa.com/t/mysql-query-php-help/266916>\
**Category:** programming\
**Created:** [July 25, 2008, 3:38pm UTC](https://forum.kirupa.com/t/mysql-query-php-help/266916 "2008-07-25T15:38:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregmax](https://avatars.discourse-cdn.com/v4/letter/g/ac8455/32.png) [@gregmax](https://forum.kirupa.com/u/gregmax)\
**Post date:** [July 25, 2008, 3:38pm UTC](https://forum.kirupa.com/t/mysql-query-php-help/266916/1 "2008-07-25T15:38:52Z")

</div>

Hello again Kirupans, I have been here a lot lately the past 48 hours… because you guys are great for advice and suggestions.

I am trying to display a simple rankings system. In the Database I have something like this:

## | user\_id | score |

| 1 | 40 |  
| 2 | 400 |  
| 3 | 30 |  
| 4 | 89 |  
| 5 | 10 |  
| 6 | 55 |

If I want to get the leaders, with the highest score at top, I would have my query something like this:

select distinct `user_id`, sum(`score`) as `score` from `score_list` group by `user_id` order by `score` desc;

This query would sort from the score list from first to last. What my problem is is trying to find out where that one user stands among the other users. For example, lets say there are 5000 "user\_id"s, and I want to find out where user\_id 5 stands among the 5000… like he could be very last or at the very top of the list… How do I find out where that user stands with out having to loop through the list?
