且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL 从另一个表中的另一列更新一列

更新时间:2022-03-17 21:35:30

根据 MySQL 文档,要进行交叉表更新,您不能使用连接(就像在其他数据库中一样),而是使用 where 子句:

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