简体   繁体   中英

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..)

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM