I have two tables like in picture below:
I change price of one product. Then I need to update total_price in table two for all customers. How to update total_price in table two in one statement for all the customers?
I have two tables like in picture below:
I change price of one product. Then I need to update total_price in table two for all customers. How to update total_price in table two in one statement for all the customers?
You could use 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