title: My sql transaction to transfer 1000 from one account to another account in a single table account(name,balance)
body: <p>My SQL transaction to transfer 1000 from one account to another account in a single table account(name, balance)?</p>
  
  <p>I wrote below query, I am not sure how to check conditions. </p>
  
  <pre><code>START TRANSACTION
  
  UPDATE account SET balance = balance - 100 WHERE name = 'D'
  
  UPDATE account SET balance = balance + 100 WHERE name = 'A'
  
  COMMIT
  </code></pre>
  
  <p>how to check conditions for sufficient amount before transfer ?</p>