开发者

How do I update a column in 3rd row the same as a column in 2nd row in MySQL?

开发者 https://www.devze.com 2022-12-31 12:06 出处:网络
I\'m doing it this way: UPDATE products SET products_image = (SELECT products_image FROM products 开发者_运维问答WHERE products_id = 2)

I'm doing it this way:

UPDATE products 
   SET products_image = (SELECT products_image 
                           FROM products 
             开发者_运维问答             WHERE products_id = 2) 
 WHERE products_id = 3;

...but get an error:

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


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号