change order of many query's with 1 query?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

change order of many query's with 1 query?

Post by potato »

hi,

i need some oppinion on a problem ive got.
I want to change the ordernr of different mysql records with one query if its possible.
for example: i've got a mysql table with following attributes: id, name, order
in this table are some records:

485, tom, 1
486, bart, 2
487, david, 3
488, pieter, 4

now i want to add a new record, but it has to have order 2, so it comes between tom and bart

like this:

485, tom, 1
486, bart, 3
487, david, 4
488, pieter, 5
489, newrecord, 2

somebody knwos how this can be done the most easy way?

many thanks to you guys!
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

viewtopic.php?t=60966 may be of interest.
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Post by potato »

thanx feyd! Just what i was looking for. :wink:
Post Reply