moving a sql row.....

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

moving a sql row.....

Post 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?
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

it doesn't matter where you put it in because you can always ORDERBY when you pull it out
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

ok thanks
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post 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.
Post Reply