user3052446
user3052446

Reputation: 1

update a whole column with the values of another column of another table mysql

I've a table named table1 like this:

column1 column2 .. columnX Name otherColumns

                      John  
                      Paul  
                      Paul  
                      Jimmy  
                      Fred  
                      Mary

I know ONLY the Name column in table1.
So in my application I read the whole Name column and encrypt each value.
Now I have to update the names of table1 with their encrypted values.
What can I do? (sorry for bad format of table..)

Upvotes: 0

Views: 55

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1271111

Assuming you have another table with columns like Name and EncryptedName, you can do the update with a join:

update table1 t1 join
       NamePairs np
       on t1.name = np.name
    set t1.name = np.EncryptedName;

Upvotes: 2

Related Questions