SQL Query Question
| From: | Andrew Brampton | Date: | Sat, 08 Dec 2001 20:47:24 +0000 |
| Subject: | SQL Query Question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-77129@lists.php.net to get a copy of this message | ||
Hi,
This isn't a php question, more of a SQL question, but I don't know any where better to
send it, and I guess its trival enough for someone here to answer.
Anyway, I have a list of members each with a score field. How can I say that Member 3 is ranked 10
out of 100 members for example.
Here is the layout of the members table:
ID, Name, Score
I can get the total count of members in the table, but I don't know how to determine what rank
they are, unless I return all the rows in the table (sorted), and cycle through them until I find
the member I want, counting how many people are above him... This method would work, but would be
slow (and wastful), is there a better way to determine his position with a SQL Query?
Thanks in advance
Andrew
P.S
If it matters I'm using MySQL & PHP 4.0.6 on WinXP under Apache 1.3.22