MySQL Insert join table statement and update field on joined table
<p>I have two table with column like this:</p>

<p><strong>Table aggthndet (Reference table)</strong></p>

<pre><code>SELECT `aggthndet`.`idaggdet`,
`aggthndet`.`idagg`,
`aggthndet`.`noakun`,
`aggthndet`.`ketdet`,
`aggthndet`.`pagu`,
`aggthndet`.`prosesagg`,
`aggthndet`.`realisasi`,
`aggthndet`.`iu_id_usr`,
`aggthndet`.`iu_wkt`,
`aggthndet`.`iu_stat`FROM `aggthndet`;
</code></pre>

<p><strong>Table aggakundet</strong></p>

<pre><code>SELECT `aggakundet`.`id`,
`aggakundet`.`idaggdet`,
`aggakundet`.`ketdetakun`,
`aggakundet`.`volume`,
`aggakundet`.`hrg_satuan`,
`aggakundet`.`iu_id_usr`,
`aggakundet`.`iu_wkt`,
`aggakundet`.`iu_stat`
FROM `aggakundet`;
</code></pre>

<p>The tables are mutually related to each other <strong>(relationship one-to-many)</strong></p>

<p>i want insert data into table <strong>aggakundet</strong>, and update column <strong>pagu</strong> on table <strong>aggthndet</strong>, <strong>pagu</strong> column is the sum of the overall <strong>jml_total (alias column)</strong> of columns that have the same <strong>idaggdet</strong>.</p>

<p><strong>sample data</strong>
<br />
<a href="https://i.stack.imgur.com/6JiN3.png" rel="nofollow noreferrer">table aggthndet</a> <br />
<a href="https://i.stack.imgur.com/vBkPb.png" rel="nofollow noreferrer">table aggakundet</a></p>