Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Alter one field in a row (300 rows)

    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

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by guelphdad View Post
    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.

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    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:

    Code:
    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.

  • #5
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, thanks will try this and get back to you if it worked or not


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •