Flow Control Statements END REPEAT [ end_label ] The statement list within a  REPEAT  statement is repeated until the  search_condition  expression is true. Thus, a  REPEAT  always enters the loop at least once.  statement_list  consists of one or more statements, each terminated by a semicolon ( ; ) statement delimiter. A  REPEAT  statement can be labeled. For the rules regarding label use, see Section 13.6.2, “Statement Labels” . mysql>  delimiter // mysql>  CREATE PROCEDURE dorepeat(p1 INT) BEGIN SET @x = 0; REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT; END // Query OK, 0 rows affected (0.00 sec) mysql>  CALL dorepeat(1000)// Query OK, 0 rows affected (0.00 sec) mysql>  SELECT @x// +------+ | @x | +------+ | 1001 | +------+ 1 row in set (0.00 sec) The  RETURN  statement terminates execution of a stored function and returns the value  expr  to the function caller. There must be at least one  RETURN  statement in a stored function. There may be more than one if the function has multiple exit points. This statement is not used in stored procedures, triggers, or events. The  LEAVE  statement can be used to exit a stored program of those types. The statement list within a  WHILE  statement is repeated as long as the  search_condition  expression is true.  statement_list  consists of one or more SQL statements, each terminated by a semicolon ( ; ) statement delimiter. A  WHILE  statement can be labeled. For the rules regarding label use, see Section 13.6.2, “Statement Labels” . CREATE PROCEDURE dowhile() RETURN  expr [ begin_label :] WHILE  search_condition  DO statement_list END WHILE [ end_label ] 13.6.5.7 RETURN Statement 13.6.5.8 WHILE Statement 2803 Example: Example: