mysql表列更新

时间:2017-11-16 03:48:55

标签: mysql sql-update

我正在尝试更新Registered_User_Contact表

Emulator Controls (default)

这是我的SQL命令:

select t1.username , t2.username, t1.registered_user_id, t2.registered_user_id from Registered_User_Contact t2 inner join Registered_User t1 on t1.username = t2.username;

-----------+------------+--------------------+--------------------+
| username   | username   | registered_user_id | registered_user_id |
+------------+------------+--------------------+--------------------+
| bose       | bose       |                  1 |               NULL |
| chiragjain | chiragjain |                  2 |               NULL |
| mike1      | mike1      |                  3 |               NULL 

1 个答案:

答案 0 :(得分:0)

您的更新加入语法已关闭。请尝试以下方法:

UPDATE Registered_User_Contact t1
INNER JOIN Registered_User t2
    ON t1.username = t2.username
SET t1.registered_user_id = t2.registered_user_id;