...

View Full Version : Alter one field in a row (300 rows)



ruud
02-28-2007, 05:31 PM
example
changing id='1' -> id=' 5000'

this must be done with over 300 ids

Is there a script ot there that can do this? instead of me doing it manually.

Thanks in Advance

Ruud

guelphdad
02-28-2007, 06:46 PM
well it doesn't explain much. are you changing all ids to 5000 more than they are now?

are they all changing to different values?

are you changing all ids in a certain range to be 5000 more than they are now?

a few more rows might help point me or someone else to a solution for you.

ruud
02-28-2007, 07:05 PM
well it doesn't explain much. are you changing all ids to 5000 more than they are now?

are they all changing to different values?

are you changing all ids in a certain range to be 5000 more than they are now?

a few more rows might help point me or someone else to a solution for you.


i got 300 members and now im merging those into a database with 5000 members, in both databases the user have id 1,2,3 and so on.

So i need a script that changes the ids for every member in the one database so they dont collide with the members in the other database cause of equal ids.

guelphdad
02-28-2007, 08:33 PM
Okay lets say you have the following two tables:

oldusers

id name
1 Jim
2 Bob
3 Terry

newusers
id name
1 John
2 Gary
4 Paul

use the following to import your users from the old table to new and reassign new ids:



insert into newusers
select id+(select max(id) from newusers), name from oldusers


That leaves you with:
newusers
id name
1 John
2 Gary
4 Paul
5 Jim
6 Bob
7 Terry

note that if you are not the only user on this database you will want to lock the table first. That's so you don't end up with the maximum value of id from the new table but have that number wrong because another user inserts a row while you are doing this.

ruud
02-28-2007, 09:40 PM
ok, thanks will try this and get back to you if it worked or not :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum