我需要获取子行的总和值并更新父行上的数据。我得到了这个,如下所示,但遇到了错误#1111(组函数的无效使用)。
CREATE TEMPORARY TABLE cms_ladu_temp LIKE cms_ladu;
INSERT INTO cms_ladu_temp SELECT * FROM cms_ladu WHERE parent_id IN (326,500);
UPDATE
cms_ladu
INNER JOIN
cms_ladu_temp
ON
cms_ladu_temp.parent_id=cms_ladu.id
SET
cms_ladu.child_packaging_units_in=SUM(cms_ladu_temp.packaging_units_in),
cms_ladu.child_net_weight_in=SUM(cms_ladu_temp.net_weight_in)
WHERE
cms_ladu.id IN (326,500);