Update 2 field in a mysql table

Discussion in 'MySQL' started by schlogo, Nov 2, 2012.

  1. #1
    Hello

    I have a mysql question for you . I need to obfuscate last names and first names to use a database in a developpement.
    3 columns are used : firstname, lastname and group

    What i needed is to rename each user to firstname1 / lastname1, next row : firstname2/lastname2 etc ... for all records where group=1

    Any idea how to create the correct sql command ?

    Tks for your help
     
    schlogo, Nov 2, 2012 IP
  2. schlogo

    schlogo Well-Known Member

    Messages:
    1,615
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    140
    #2
    I ve found the answer on another forum: I have updated the name field with a default value

    UPDATE table SET name=user

    Done the same with the last name column

    Then i ve updated again the name column concatanating the lastname (same for everyone) with the user id

    UPDATE table SET name=CONCAT(name,userid)

    Works perfectly
     
    schlogo, Nov 3, 2012 IP