直接看SQL:
-- 同步某表数据 2020年11月7日17:15:36
UPDATE
lb_order o,
(
SELECT
IFNULL(SUM(g.cost_price),0) cost_price,
ogl.order_sn
FROM lb_order_goods_list ogl
LEFT JOIN lb_goods g ON g.id = ogl.goods_id
GROUP BY ogl.order_sn
) b
SET o.cost_price_total = b.cost_price
WHERE o.order_sn = b.order_sn