0

我想将一行从一个表更新到另一个表

我正在尝试这样的事情:

INSERT INTO ps_product_shop (id_category_default)
SELECT Distinct id_category_default
FROM ps_product
WHERE id_product BETWEEN 1 AND 6226

但是我得到主键错误我需要将 id_category_default 的值从 ps_product 更改为 ps_product_shop

谢谢

4

1 回答 1

0

这是你要找的吗?

UPDATE ps_product_shop prod_shop
INNER JOIN ps_product prod USING(id_product)
SET prod_shop.id_category_default = prod.id_category_default
WHERE prod_shop.id_product BETWEEN 1 AND 6226
于 2012-12-11T00:00:38.607 回答