MySQL: SELECT a Winner, returning their rank

Posted by incrediman on Stack Overflow See other posts from Stack Overflow or by incrediman
Published on 2010-03-19T23:24:52Z Indexed on 2010/03/19 23:41 UTC
Read the original article Hit count: 345

Filed under:
|
|

Earlier I asked this question, which basically asked how to list 10 winners in a table with many winners, according to their points.

This was answered.

Now I'm looking to search for a given winner X in the table, and find out what position he is in, when the table is ordered by points.

For example, if this is the table:

     Winners:
NAME:____|__POINTS:
Winner1  |  1241
Winner2  |  1199
Sally    |  1000
Winner4  |  900
Winner5  |  889
Winner6  |  700
Winner7  |  667
Jacob    |  623
Winner9  |  622
Winner10 |  605
Winner11 |  600
Winner12 |  586
Thomas   |  455
Pamela   |  434
Winner15 |  411
Winner16 |  410

These are possible inputs and outputs for what I want to do:

Query:  "Sally", "Winner12", "Pamela", "Jacob"
Output: 3        12          14        623

How can I do this? Is it possible, using only a MySQL statement? Or do I need PHP as well?

This is the kind of thing I want:

WHEREIS FROM Winners WHERE Name='Sally' LIMIT 1

Ideas?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql