title: How to declare cursor in phpmyadmin?
body: <p>When I add this code I have an error and I can't able to repair it.</p>
  
  <pre><code>DECLARE c1 cursor FOR SELECT i FROM integers;
  OPEN c1;
  FETCH c1 INTO L1;
  FETCH c1 INTO L2;
  FETCH c1 INTO L3;
  FETCH c1 INTO L4;
  FETCH c1 INTO L5;
  FETCH c1 INTO L6;
  CLOSE c1;    
  </code></pre>
  
  <p>Below is full code. Without the code, which is above, procedure executes and return six rows with no duplicate numbers from integer table, which I'd like to write to L1,L2,L3,L4,L5,L6 and later insert into table kupony. 'howMany' is IN procedure parameter.</p>
  
  <pre><code>DELIMITER $$
  
  CREATE PROCEDURE addTickets (IN howMany INT)
  BEGIN
  
  DECLARE L1 INT default 0;
  DECLARE L2 INT default 0;
  DECLARE L3 INT default 0;
  DECLARE L4 INT default 0;
  DECLARE L5 INT default 0;
  DECLARE L6 INT default 0;
  DECLARE count1 INT;
  set count1 = 0;
  
  
  while count1 &lt; howMany DO
  DECLARE c1 FOR SELECT i FROM integers WHERE i BETWEEN 1 AND 49 ORDER BY RAND() LIMIT 6;
  OPEN c1;
  FETCH c1 INTO L1;
  FETCH c1 INTO L2;
  FETCH c1 INTO L3;
  FETCH c1 INTO L4;
  FETCH c1 INTO L5;
  FETCH c1 INTO L6;
  CLOSE c1;    
  INSERT INTO kupony VALUES(NULL, 1, L1, L2, L3, L4, L5, L6, -1, '2018-01-01', -1);
  set count1 = count1 + 1;
  end while;
  
  END$$
  
  DELIMITER ;
  </code></pre>