title: MySQL question: The right way to calculate some data from different tables
body: <p>We have a table <code>A</code> in which we store data about user investments; example columns <code>user_id</code>, <code>project_id</code>, <code>amount</code>.</p>
  
  <p>We also have a table <code>B</code> in which we store data about projects and the total amount of investments; columns <code>project_id</code> and <code>total_amount</code>.</p>
  
  <p>With PHP we can count the amount from <code>A</code> and write <code>total_amount</code> to <code>B</code>.</p>
  
  <p><strong>The question:</strong> Is it possible at the MYSQL level to automatically calculate data in order to avoid unnecessary operations in PHP?</p>
  
  <p>If Yes, could you show me an example?</p>