3 types of loops in MySQL stored program: - Simple loop using LOOP and END LOOP clauses - WHILE and END WHILE clauses that runs while a condition is true - REPEAT and UNTIL clauses that runs until a condition is true
Termination of loop -> LEAVE statement. I will demonstrate the use of loops the simple loop way.
Simple counter from 1 to 10:
Store below stored procedure in a file named my_loop.sql
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.