title: How to make sure there is no race condition in MySQL database when incrementing a field?
body: <p>How to prevent a race condition in MySQL database when two connections want to update the same record?</p>
  
  <p>For example, connection 1 wants to increase "tries" counter. And the second connection wants to do the same. Both connections <code>SELECT</code> the "tries" count, increase the value and both <code>UPDATE</code> "tries" with the increased value. Suddenly "tries" is only "tries+1" instead of being "tries+2", because both connections got the same "tries" and incremented it by one.</p>
  
  <p>How to solve this problem?</p>