table_a (item_id, item_desc)
table_b (item_id, item_name)
table_c (item_name, item_desc)
我需要设置 table_a.item_desc=table_c.item_desc
无论我在做什么,我仍然会遇到错误。
这是我的最终作品:
UPDATE table_a
SET table_a.item_desc = table_c.item_desc
FROM table_a
INNER JOIN table_b
ON table_a.item_id = table_b.item_id
INNER JOIN table_c
ON table_b.item_name = table_c.item_name;
最佳答案
你有语法错误。在 MySQL 中,当使用 UPDATE
和 JOIN
时,您不需要添加 FROM
子句。
还添加表别名以提高可读性。
UPDATE table_a A
INNER JOIN table_b B ON A.item_id = B.item_id
INNER JOIN table_c C ON B.item_name = C.item_name
SET A.item_desc = C.item_desc ;
关于mysql - 从 3 个表中更新 SET 信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37855951/