通过在MYSQL中连接多个表来更新表

时间:2014-10-09 04:04:45

标签: mysql

您好我想更新我的桌子,但它给我一个错误。

ERROR 1064 (42000): You have an error in your SQL syntax;

这是我的剧本

UPDATE table1 
SET last_name = table3.lastname, 
first_name = table3.firstname,
FROM table1
INNER JOIN table2
ON table2.entity_id = table1.entity_id
INNER JOIN table3
ON table3.biometric_id = table2.biometric_id;

1 个答案:

答案 0 :(得分:1)

这应该可以帮助您使用MySql - UPDATE... JOIN... SET...

UPDATE table1 t1 
    JOIN table2 t2
        ON t2.entity_id = t1.entity_id
    JOIN table3 t3
        ON t3.biometric_id = t2.biometric_id;
SET t1.last_name = t3.lastname,
    t1.first_name = t3.firstname