I have a database that has a similar structure to:
http://www.sqlfiddle.com/#!2/6c5239
Currently in a .php
script to find the rank of the person I run
SELECT * FROM people ORDER BY score DESC;
and loop through the results, increment a "rank"
variable each row until I hit the desired name, output the results, and break the loop.
I feel this is a very inefficient way to get a ranking, both for the webserver to have to loop through the data and also for the SQL database to return an entire table.
Is there an easier way to do this, possibly all through a SQL statement that doesn't tax the SQL server too much?