NL_Johan_UK Posted March 29, 2003 Share Posted March 29, 2003 Hey everybody! 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. Imaginary Query: 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? Cheers.... Quote Link to comment Share on other sites More sharing options...
vhkristof Posted March 30, 2003 Share Posted March 30, 2003 Well, 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 Quote Link to comment Share on other sites More sharing options...
DocSeuss Posted March 30, 2003 Share Posted March 30, 2003 auto increment was only intended to \"automatically\" assign a unique identifier for a new row. If it is important to your project that all of the entries have a field where each one is identified sequencially? You will have to do that manualy with the code. Maybe if you tell us why the holes are causeing you grief we can suggest a different way of doing things. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.