title: MySQL Summing across multiple tables
body: <p>I have four tables, each looks like </p>
  
  <pre><code>ID    Value
  1     23.43
  2     34.23
  1     32.23
  3     11.25
  </code></pre>
  
  <p>There can be multiple value entries for each ID within each table.  Each ID has values in all four tables. </p>
  
  <p>I want to write a query that gives me the aggregated results per ID.  I want to add two of the tables' values and subtract the other two's values from the aggregate. </p>
  
  <p>If were to be writing this in pseudocode:</p>
  
  <pre><code>foreach ID
      sumTable1 = sum(Table1.value) where ID=ID
      sumTable2 = sum(Table2.value) where ID=ID
      sumTable3 = sum(Table3.value) where ID=ID
      sumTable4 = sum(Table4.value) where ID=ID
      print ID . ": " . sumTable1+sumTable2-sumTable3-sumTable4
  </code></pre>
  
  <p>Can I do this in a single mySQL query?</p>