title: Are all effected tables "locked" by mySQL transactions?
body: <p>I want to do a financial transaction but I am not really familiar with MySQL transaction feature.</p>
  
  <p>I want to get sure that I am doing all things right. My goal is to "lock" my transactionHistory and transactionQueued table during my transaction in order to be sure that the account balance is correct and no other transaction can be inserted manipulate the balance / meanwhile.</p>
  
  <pre><code>SET autocommit=0;
  START TRANSACTION;
  
  IF (
  SELECT SUM(amount) of transactionHistory WHERE account = 1
  +
  SELECT SUM(amount) of transactionsQueued WHERE account = 1)
  
   &gt;= :amount)
  
  INSERT INTO transactionHistory (account, amount) VALUES (1, -:amount);
  INSERT INTO transactionHistory (account, amount) VALUES (2, :amount);
  
  COMMIT;
  </code></pre>
  
  <p>Is it right that mySQL locks all effected tables? In this case transactionHistory and transactionsQueued.</p>
  
  <p>I am using innoDB and this code is not part of a procedure.</p>
  
  <p>Thank you!</p>