The syntax for the WHILE statement in MySQL is:
Parameters or Arguments
Optional. It is a name associated with the WHILE loop.
Te condition is test each pass through the WHILE loop. If the condition evaluates to TRUE, the loop body is executed. If the condition evaluates to FALSE, the WHILE loop is terminated.
The statements of code to execute each pass through the WHILE loop.
Let's look at an example that shows how to use the WHILE statement in MySQL:
In this WHILE LOOP example, the loop would terminate once income exceeded 3000 as specified by:
The WHILE LOOP will continue while income = 3000. And once income is > 3000, the loop will terminate.