title: MySQL Trigger IF syntax error
body: <p>I was creating some triggers (using MySQL Workbench), and got an error regarding the if statement in one of them. Here it is:</p>
  
  <pre><code>CREATE DEFINER = CURRENT_USER TRIGGER `mydatabase`.`transactions_AFTER_UPDATE` AFTER UPDATE ON `transactions` FOR EACH ROW
  begin
  
  if (old.idUser != new.idUser) then
      signal sqlstate '45000' set message_text = "Can't change transactions' initiator.";
  end if;
  declare oldAmountTokens integer;
  SET @oldAmountTokens = (SELECT tokens from offers WHERE idoffer = old.idOffer);
  declare newAmountTokens integer;
  SET @newAmountTokens = (SELECT tokens from offers WHERE idoffer = new.idOffer);
  declare diff integer;
  SET @diff = @newAmountTokens - @oldAmountTokens;
  UPDATE users SET tokens = users.tokens + @diff WHERE idUser = new.idUser;
  end
  </code></pre>
  
  <p>MySQL Workbench tells me </p>
  
  <p><code>"missing 'end'" at line 6</code> (where the 'end if;' is), </p>
  
  <p>and phpMyAdmin tells me </p>
  
  <pre><code>"#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 '' at line 5".
  </code></pre>
  
  <p>I'm really stuck on this, so I'd be really happy if someone could help me, I've searched for the IF syntax on the web, but I don't see anything wrong...</p>