I am using mysql.i have 2 tables NOTE_ONE and NOTE_TWO. each table has three columns as ID and NAME and MID. i need to update NOTE_TWO table's MID column with data from MID column of NOTE_ONE. but condition is NOTE_ONE and NOTE_TWO tables NAME should be equal. PLease suggest me how to write query for this?
Thanks!
This should do the trick,
UPDATE NOTE_TWO n2, NOTE_ONE n1
SET n2.MID = n1.MID
WHERE n1.NAME = n2.NAME
Hope this helps
尝试这个
UPDATE note_two n2 set mid = (SELECT mid from note_one n1 where n1.name = n2.name)
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.