title: MYSQL If statement in transaction causing error
body: <p>I have the following MYSQL query:</p>
  
  <pre><code>START TRANSACTION;
  
  SELECT sport_id INTO @a FROM sports WHERE sport_id = 2 FOR UPDATE;
  
  UPDATE sports SET sport_name = 'Table Tennis' WHERE sport_id = @a;
  
  if (@a &gt; 1) then
      COMMIT;
  ELSE
      ROLLBACK;
  END IF;
  </code></pre>
  
  <p>The problem is that it returns an error at the if statement:</p>
  
  <blockquote>
    <p>#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if (@a > 1) then COMMIT' at line 1</p>
  </blockquote>
  
  <p>I've looked on stack overflow and there is an <a href="https://stackoverflow.com/a/9327843/894792">answer showing a similar query</a>, written in pretty much the same way, but they are using the variable without an <code>@</code> symbol.  Removing the <code>@</code> for my query does not resolve the issue.</p>
  
  <p>This is just a test query to try out some transactions using MYSQL, hence why the query seems a little pointless.  I'm a little stuck.</p>