13.6.5 Flow Control Statements

13.6.5.1 CASE Syntax
13.6.5.2 IF Syntax
13.6.5.3 ITERATE Syntax
13.6.5.4 LEAVE Syntax
13.6.5.5 LOOP Syntax
13.6.5.6 REPEAT Syntax
13.6.5.7 RETURN Syntax
13.6.5.8 WHILE Syntax

MySQL supports the IF, CASE, ITERATE, LEAVE LOOP, WHILE, and REPEAT constructs for flow control within stored programs. It also supports RETURN within stored functions.

Many of these constructs contain other statements, as indicated by the grammar specifications in the following sections. Such constructs may be nested. For example, an IF statement might contain a WHILE loop, which itself contains a CASE statement.

MySQL does not support FOR loops.