Page 1 of 1

moving a sql row.....

Posted: Thu Apr 01, 2004 4:45 pm
by dull1554
i have a table of high scores on a game, if there is a new high score i want to move down all the entrys to make way for the new high score, is there an easy to move a row in a table(mysql) to another row?

Code: Select all

mysql_query("SELECT * FROM highscores WHERE id='a number' MOVE TO id='another number'");
i know this does not work but is there something that would do the same thing?

Posted: Thu Apr 01, 2004 5:15 pm
by magicrobotmonkey
it doesn't matter where you put it in because you can always ORDERBY when you pull it out

Posted: Thu Apr 01, 2004 5:36 pm
by pickle
In order to move rows in MySQL, you'd have to get all the info out of the table, delete everything from the table, then add all the data back in in the required order. It's MUCH MUCH easier to do it just like ~magicrobotmonkey suggested.

Posted: Thu Apr 01, 2004 6:14 pm
by dull1554
ok thanks

Posted: Fri Apr 02, 2004 2:28 am
by Wayne
dull you seem to be missing the whole point of what a datbase is and does, that is why we have relational databases, you can get the infomation out in whatever order you want it in, regardsless of when it was added, as long as you have something to identify the order it should be in ie. the score or the percentage in this case.