title: Problem Setting Variable value in MySQL Procedure
body: <p>Having trouble setting the value of a declared variable in MySQL. If I run the following in MySQL Command Line it all works great:  </p>
  
  <pre><code>SET @numberOfMonths = (SELECT COUNT(\*) FROM (SELECT DISTINCT months WHERE year = 2010) as A);  
  SELECT @numberOfMonths;  
  </code></pre>
  
  <p>So it returns 6 for this particular example.<br>
  If I do the following I don't have any problems either:    </p>
  
  <pre><code>DELIMITER @@  
  CREATE PROCEDURE GetPropertyTenantPayment()    
  BEGIN  
  DECLARE done INT DEFAULT 0;   
  DECLARE numberOfMonths INT DEFAULT 6;  
  ....  
  END;  
  @@  
  </code></pre>
  
  <p>No, problem, the procedure works as it should but once I do this:  </p>
  
  <pre><code>DELIMITER @@  
  CREATE PROCEDURE GetPropertyTenantPayment()  
  BEGIN    
  DECLARE done INT DEFAULT 0;  
  DECLARE numberOfMonths INT;  
  SET numberOfMonths = (SELECT COUNT(\*) FROM (SELECT DISTINCT month WHERE year = 2010) as A);    
  ...  
  END;  
  @@
  </code></pre>
  
  <p>I get a syntax error at the SET numberOfMonths line. I don't really understand why? I do the same outside of the procedure and there is no problem. Thanks for the help!</p>