title: SQL Joining table and minus based on column data
body: <p>I have 3 tables,</p>
  <p>budget:</p>
  <p><a href="https://i.stack.imgur.com/M4sIf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M4sIf.png" alt="enter image description here" /></a></p>
  <p>budgetexpense:</p>
  <p><a href="https://i.stack.imgur.com/6YNBB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6YNBB.png" alt="enter image description here" /></a></p>
  <p>expense:</p>
  <p><a href="https://i.stack.imgur.com/NV1JB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NV1JB.png" alt="enter image description here" /></a></p>
  <p>What the table means is basically, a user will insert a budget amount for a specific expense category in <code>budgetexpense</code>. Then, the sum of this value will be inserted into the <code>budgetamount</code> column in the <code>budget</code> table. Then, the user will be able to add expenses based on specific categories in <code>expense</code> table.</p>
  <p>What I want to know, if there is a way to join both <code>budgetexpense</code> and <code>expense</code> table, and be able to minus the amount from <code>budgetexpense</code> with <code>expense</code> based on their categories. For example, transport from <code>budgetexpense</code> table must only minus with transport from <code>expense</code> table.</p>
  <p>Apologies if my explanation is a little messy. Let me know and I'll try to explained to you again better.</p>