table_a(item_id,item_desc)
table_b(item_id,item_name)
table_c(item_name,item_desc)
我需要set 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;
答案 0 :(得分:0)
您有语法错误。在MySQL中,FROM
与UPDATE
一起使用时,您不需要添加JOIN
子句。
还要添加表别名以提高可读性。
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 ;
答案 1 :(得分:0)
在MySQL中,连接部分紧跟在update
关键字后面,而不是在语句的末尾:
UPDATE 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
SET table_a.item_desc = table_c.item_desc;
答案 2 :(得分:0)
尝试此操作,因为更新JOIN
将在SET
UPDATE 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
SET table_a.item_desc = table_c.item_desc;