在同一个表上将一列复制到另一列

时间:2016-01-20 19:56:48

标签: mysql

我正在尝试将products_description_second中的值复制到language_id = 3的同一列,所以我到目前为止:

UPDATE pd1 SET
     pd1.products_description_second = pd2.products_description_second
from products_description pd1 
    join products_description pd2 on pd1.products_id = pd2.products_id and  pd2.language_id = 3
WHERE pd2.language_id = 1

但是我收到了语法错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from products_description pd1 join products_description pd2 on pd1.product' at line 3

我错过了什么?

1 个答案:

答案 0 :(得分:0)

您的语法不正确。这应该工作

UPDATE products_description pd1  
JOIN products_description pd2 on pd1.products_id = pd2.products_id and pd2.language_id = 3
SET pd1.products_description_second = pd2.products_description_second
WHERE pd2.language_id = 1