Find row number
Posted 29 March 2003 - 05:41 PM
Maybe someone can help with the following...
I have a table with player names and their scores. To display the ranking I select names and scores and sort by scores desc.
Now I can while-loop my way through the whole list. No problems.. BUT:
Now I want to find only one persons position in the rankings table.
SELECT row_number, names, scores FROM thetable WHERE name=\'$name\' ORDER BY scores desc
echo hey dude you are $row_number i nthe rankings!
How can I get this number? Do i need to make a temp field named ranking or something? Can I auto increment this temp field?
Id like to do this on the database side so i dont have to pull all data through the pipe for just one dude...
The scores change so often I dont want to save their positions in a field.
If I understand correctly, I think I need an inverse of mysql_data_seek. So instead of giving the pointer and getting the data, I need to give the data (name) and get the pointer (position in table).
Is this possible?
Posted 30 March 2003 - 08:42 AM
I don\'t know if this will work, but I know that in Oracle you have
a statement called ROWID...so this would be like
SELECT ROWID AS \'rank\', column1, column2 FROM table WHERE rank = 2
I don\'t know if this will work ..., let me know
Posted 30 March 2003 - 11:53 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users