
update accept_orders as a 
  left join (
    select accept_order_id, SUM(quantity) AS total_quantity from accept_order_details group by accept_order_id
  ) as b on a.id=b.accept_order_id
  set a.total_quantity=b.total_quantity;
  
update orders as a 
  left join (
    select order_id, SUM(quantity) AS total_quantity from order_details group by order_id
  ) as b on a.id=b.order_id
  set a.total_quantity=b.total_quantity;
  
update purchases as a 
  left join (
    select purchase_id, SUM(quantity) AS total_quantity from purchase_details group by purchase_id
  ) as b on a.id=b.purchase_id
  set a.total_quantity=b.total_quantity;
  
update sales as a 
  left join (
    select sale_id, SUM(quantity) AS total_quantity from sale_details group by sale_id
  ) as b on a.id=b.sale_id
  set a.total_quantity=b.total_quantity;
  
update shippings as a 
  left join (
    select shipping_id, SUM(quantity) AS total_quantity from shipping_details group by shipping_id
  ) as b on a.id=b.shipping_id
  set a.total_quantity=b.total_quantity;
  
update restorations as a 
  left join (
    select restoration_id, SUM(quantity) AS total_quantity from restoration_details group by restoration_id
  ) as b on a.id=b.restoration_id
  set a.total_quantity=b.total_quantity;
  
update disposals as a 
  left join (
    select disposal_id, SUM(quantity) AS total_quantity from disposal_details group by disposal_id
  ) as b on a.id=b.disposal_id
  set a.total_quantity=b.total_quantity;
  
update samples as a 
  left join (
    select sample_id, SUM(quantity) AS total_quantity from sample_details group by sample_id
  ) as b on a.id=b.sample_id
  set a.total_quantity=b.total_quantity;
  
update adjustments as a 
  left join (
    select adjustment_id, SUM(quantity) AS total_quantity from adjustment_details group by adjustment_id
  ) as b on a.id=b.adjustment_id
  set a.total_quantity=b.total_quantity;
  
