【问题标题】:How do I update a column in 3rd row the same as a column in 2nd row in MySQL?如何将第三行中的列更新为与 MySQL 中第二行中的列相同?
【发布时间】:2011-02-22 15:13:38
【问题描述】:

我是这样做的:

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

...但出现错误:

ERROR 1093 (HY000): You can't specify target table 'products' for update in FROM 子句

【问题讨论】:

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


    【解决方案1】:
    UPDATE products p1, products p2 
    SET p1.products_image=p2.products_image 
    WHERE p1.id=3 AND p2.id=2;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-25
      • 2018-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多