1-- MySQL LOOP, ITERATE, LEAVE, loop label
2CREATE PROCEDURE LoopDemo()
3BEGIN
4 DECLARE x INT;
5 DECLARE str VARCHAR(255);
6 SET x = 1;
7 SET str = '';
8 loop_label: LOOP
9 IF x > 10 THEN
10 LEAVE loop_label;
11 END IF;
12 SET x = x + 1;
13 IF (x mod 2) THEN
14 ITERATE loop_label;
15 ELSE
16 SET str = CONCAT(str,x,',');
17 END IF;
18 END LOOP;
19 SELECT str;
20END$$