The code for LoopDemo.sql is: DROP PROCEDURE IF EXISTS LoopDemo; DELIMITER $$ CREATE PROCEDURE LoopDemo() BEGIN DECLARE x INT; DECLARE str VARCHAR(255); SET x = 0; SET str = ''; loop_label: LOOP IF x > 10 THEN LEAVE loop_label; # Exit the loop entirely. END IF; SET x = x + 1; IF (x mod 2) THEN ITERATE loop_label; # Do not execute statements below this. #ELSE #SET str = CONCAT(str,x,','); END IF; SET str = CONCAT(str,x,','); END LOOP; SELECT str; END$$ DELIMITER ; CALL LoopDemo();