Mysql 如何动态求和数据
我有两张表,如下图所示: 我改变一种产品的价格。然后我需要为所有客户更新表2中的总价。Mysql 如何动态求和数据,mysql,Mysql,我有两张表,如下图所示: 我改变一种产品的价格。然后我需要为所有客户更新表2中的总价。 如何在一个报表中为所有客户更新表2中的总价?您可以使用update with join update table_two t2 inner join ( select id_customer, sum(price) tot group by id_customer ) t1 t1.id_customer = t2.id_customer set t2.total_price = t1.to
如何在一个报表中为所有客户更新表2中的总价?您可以使用update with join
update table_two t2
inner join (
select id_customer, sum(price) tot
group by id_customer
) t1 t1.id_customer = t2.id_customer
set t2.total_price = t1.tot
不将数据样本发布为图像,仅将样本发布为表格文本。。