如何更新第3行中的列与MySQL中第2行中的列相同?

时间:2010-05-22 04:03:57

标签: mysql sql sql-update mysql-error-1093

我这样做:

UPDATE products 
   SET products_image = (SELECT products_image 
                           FROM products 
                          WHERE products_id = 2) 
 WHERE products_id = 3;

...但收到错误:

  

ERROR 1093(HY000):您无法在FROM子句中指定要更新的目标表'产品'

1 个答案:

答案 0 :(得分:5)

UPDATE products p1, products p2 
SET p1.products_image=p2.products_image 
WHERE p1.id=3 AND p2.id=2;