update 产品 set 库存量=库存量-总数量 from 产品 inner join (select 订单明细.产品ID, sum(数量) as 总数量from 订单明细group by 订单明细.产品ID) a on 产品.产品ID=a.产品ID;