ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
**1. 语法** ```sql [label:]REPEAT statements UNTIL end_condition END REPEAT [label] - end_condition:条件为真退出循环,为假则继续循环 ``` **2. 演示** ```sql delimiter $ create function fun_add_repeat(count int(11)) returns int begin declare sum int default 0; repeat set sum = sum + 1; set count = count - 1; until count <= 0 end repeat; return sum; end $ mysql> select fun_add_repeat(5) $ +-------------------+ | fun_add_repeat(5) | +-------------------+ | 5 | +-------------------+ ```