SQL update one column from another column in another table

前端 未结 2 1276
清歌不尽
清歌不尽 2020-12-28 17:55

I read various post\'s prior to this. but none of them seemed to work for me.

As the title suggests, I am trying to update one column from a column in another table

2条回答
  •  醉话见心
    2020-12-28 18:28

    According to MySQL documentation, to do a cross table update, you can't use a join (like in other databases), but instead use a where clause:

    http://dev.mysql.com/doc/refman/5.0/en/update.html

    I think something like this should work:

    UPDATE User_Settings, Contacts
        SET User_Settings.Contact_ID = Contacts.ID
        WHERE User_Settings.Account_ID = Contacts.Account_ID
    

提交回复
热议问题