How to I mass alter a MySQL database?

Discussion in 'MySQL' started by egdcltd, May 13, 2007.

  1. #1
    I have a database, and I want to alter all rows for a field in a specific table, but I don't know the sql command I should use.

    eg, for table 'bnt_ships' I want to set all rows in the field 'score' to '0'. I'm not quite sure how to do it.
     
    egdcltd, May 13, 2007 IP
  2. alamster

    alamster Peon

    Messages:
    41
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    type in phpmyadmin sql query windows

    update bnt_ships set score=0;

    //will update all score to 0

    update bnt_ships set score=0 where condition bla..bla ;

    // will update only if condition meet.
     
    alamster, May 13, 2007 IP
  3. egdcltd

    egdcltd Peon

    Messages:
    691
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks. I was on the right lines, but the actual code required wan't in my reference books.
     
    egdcltd, May 14, 2007 IP
  4. egdcltd

    egdcltd Peon

    Messages:
    691
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Slight variation of this.

    For the table phpbb_adr_shops_items how do I update the table so that the column item_restrict_level has the same value as the column item_power?
     
    egdcltd, Jun 21, 2007 IP
  5. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    try this:
    UPDATE phpbb_adr_shops_items SET item_restrict_level=column_item_power
    Code (markup):
     
    UnrealEd, Jun 21, 2007 IP
  6. egdcltd

    egdcltd Peon

    Messages:
    691
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks, got it to work
     
    egdcltd, Jun 21, 2007 IP