MySQL Repeat
MySQL Repeat
MySQL Repeat syntax and example.
The statement list within a REPEAT statement is repeated until the search_condition expression is true.
MySQL Repeat syntax
[ begin_label: ] REPEAT
statement_list
UNTIL search_condition
END REPEAT [ end_label ]
Repeat example
CREATE PROCEDURE repeat_proc(x INT) BEGIN DECLARE total INT; SET total = 0; REPEAT SET total = total + 1; UNTIL total > x END REPEAT; SELECT total; END; CALL repeat_proc(10);
Output
PROCEDURE REPEAT_PROC compiled
total
11