MySQL Iterate

MySQL Iterate

Iterate means that mysql loop can start again.
MySQL Iterate syntax and example.

Iterate example

CREATE PROCEDURE iterate_proc(x INT)
BEGIN
  p_label: LOOP
    SET x = x + 1;
    IF x < 5 THEN
      ITERATE p_label;
    END IF;
    LEAVE p_label;
  END LOOP p_label;
  SET @x = x;
END;

Output

PROCEDURE ITERATE_PROC compiled