title: Mysql nested while loop in a Stored Procedure
body: <p>currently i am working on one Stored Procedure in which i am using one while loop under another while loop. but i am not getting expected result. the most outer loop is iteration just one time.</p>
  
  <p>I am trying following code.</p>
  
  <pre><code>DELIMITER $$
  
  DROP PROCEDURE IF EXISTS `First_Sp` $$
  CREATE DEFINER=`root`@`localhost` PROCEDURE `First_Sp`()
  BEGIN
  
    DECLARE first_while_start  INTEGER DEFAULT 1;
    DECLARE second_while_start INTEGER DEFAULT 1;
    DECLARE first_while_count  INTEGER DEFAULT 3;
    DECLARE second_while_count INTEGER DEFAULT 3;
  
    WHILE first_while_start &lt; first_while_count
    DO
      WHILE second_while_start &lt; second_while_count
      DO
        SELECT concat(first_while_start,' - ',second_while_start) as result;
        SET second_while_start = second_while_start + 1;
      END WHILE;
      SET first_while_start = first_while_start + 1;
    END WHILE;
  END $$
  
  DELIMITER ;  
  </code></pre>
  
  <p>Result : </p>
  
  <pre><code>mysql&gt; call first_sp();
  +--------+
  | result |
  +--------+
  | 1 - 1  |
  +--------+
  1 row in set (0.00 sec)
  
  +--------+
  | result |
  +--------+
  | 1 - 2  |
  +--------+
  1 row in set (0.00 sec)
  
  Query OK, 0 rows affected (0.00 sec).
  </code></pre>
  
  <p>I also Tried Repeat Loop. but still no LUCK.</p>
  
  <pre><code>DELIMITER $$
  
  DROP PROCEDURE IF EXISTS `First_Sp` $$
  CREATE DEFINER=`root`@`localhost` PROCEDURE `First_Sp`()
  BEGIN
  
    DECLARE first_while_start  INTEGER DEFAULT 1;
    DECLARE second_while_start INTEGER DEFAULT 1;
    DECLARE first_while_count  INTEGER DEFAULT 3;
    DECLARE second_while_count INTEGER DEFAULT 3;
  
    REPEAT
      WHILE second_while_start &lt; second_while_count
      DO
        SELECT concat(first_while_start,' - ',second_while_start) as result;
        SET second_while_start = second_while_start + 1;
      END WHILE;
      SET first_while_start = first_while_start + 1;
    UNTIL first_while_start &lt; first_while_count
    END REPEAT;
  
  END $$
  
  DELIMITER ;
  </code></pre>
  
  <p>I am not much of SQL Developer. I am trying.</p>