这个位工作得很好:
SELECT products_id, sum(attributes_stock)
FROM products_attributes
GROUP BY products_id
Run Code Online (Sandbox Code Playgroud)
这会将attributes_stock列中的所有字段组合在一起.
我遇到的问题是将此结果更新为另一个表中的另一列.
这就是我所拥有的:
UPDATE products, products_attributes
SET products.products_quantity = sum(products_attributes.attributes_stock) GROUP BY products_attributes.products_id
WHERE products.products_id = products_attributes.products_id
Run Code Online (Sandbox Code Playgroud)
任何建议都非常感谢.