title: How to update a SQL table based on record count no of another table?
body: <p>I have two SQL tables named as <code>Share</code> and <code>Balance</code>. <code>users</code> is common column in both table.  There are multiple rows/share for each user in <code>Share</code> table. </p>
  
  <p>What I need to do is update <code>paid</code> column from <code>Share</code> table by adding 1 on each share and that added count no needs to be added in <code>balance</code> column of  <code>Balance</code> table. Say, a user has 3 rows/shares in <code>Share</code> table and if i add +1 for each share then in <code>balance</code> column of <code>Balance</code> table needs to add 3 with existing balance.</p>
  
  <p>I have written following sql statement. It is updating <code>Share</code> table accordingly but <code>Balance</code> table is updating wrong. See the image below:</p>
  
  <p><a href="https://i.stack.imgur.com/3ZFCu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3ZFCu.png" alt="table share"></a></p>
  
  <pre><code>Update Share Set paid=paid + 1
  Update Balance Set balance=balance + S.Paid
  From balance B,share S Where B.users=S.users
  </code></pre>