title: Nested loop in mysql stored procedure
body: <p>I am having a simple nested while loop in stored procedure , but it's giving an error.
  The loop does not nothing great, just for learning purpose i created two loops.</p>
  
  <pre><code>delimiter $$
  create procedure getSum(in input int , out output int)
  begin
  
  set output = 0;
  while input &gt;= 1 do
  
    declare tmp int default 1;
    while tmp &lt;= 5 do
        set  output = output + input ;
        set tmp = tmp + 1;
     end while ;
  
  set input = input - 1 ;
  
  end while;
  
  end $$
  delimiter ;
  </code></pre>
  
  <p>Below is the error</p>
  
  <p><strong><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 'declare tmp int default 1; while tmp &lt;= 5 do set output = output + inpu' at line 7</code></strong></p>
  
  <p>Thanks.</p>