2014-10-09 81 views
0

嗨,我想更新我的表格,但它給了我一個錯誤。在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; 
+0

可能重複http://stackoverflow.com/questions/8057565/mysql-update-statement-inner-join-tables – Logan 2014-10-09 04:12:51

回答

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 
+0

嗨,謝謝!它現在有效!大幫助。 – akbsmile 2014-10-09 05:09:52