我想将一行中的行更新为另一个
我正在尝试这样的事情:
INSERT INTO ps_product_shop (id_category_default)
SELECT Distinct id_category_default
FROM ps_product
WHERE id_product BETWEEN 1 AND 6226
但我得到主键错误 我需要将值从ps_product更改为ps_product_shop以获取id_category_default
由于
答案 0 :(得分: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