1. 存储过程
delimiter // -- 分块
-- 创建
drop procedure if exists test;
create procedure test(in count int)
begin
declare i int;
set i = 1;
while (i < count) do
select * from job;
set i = i + 1;
end while;
end; //
-- 执行
set @count = 10;
call test(@count);
另一种循环
loop_label:loop
select * from job;
set i = i + 1;
if i >= count THEN
leave loop_label;
end if;
end loop;
-----------待更------------
2. 函数
3. 触发器