Mysql更新列,其中包含来自另一个表的值。错误:“计数不匹配”

时间:2015-11-09 15:09:50

标签: mysql sql

我遇到这种情况:

ASSET

enter image description here

USERS

enter image description here

现在我想在设备表上删除name \ surname列,并用user表的相对id_users填充id_users。

样品:

enter image description here

我尝试过这些查询:

1)

 UPDATE asset t1 
            INNER JOIN users t2 
                 ON t1.name = t2.name and t1.surname = t2.surname
    SET t1.id_users = t2.id_users

2)

UPDATE asset 
    SET asset.id_users = (
        SELECT users.id_users
        FROM users
        WHERE asset.name = users.name AND asset.surname = users.surname
    );

两个查询我都收到此错误:

#1136 - Column count doesn't match value count at row 1
你能帮帮我吗?

0 个答案:

没有答案