drop procedure if exists setUserRole;
.....
create procedure setUserRole(userId int, startnum int,endNum int)
begin
declare i int;
set i = startnum;
while i< endNum do
INSERT into sys_user_role(user_id,role_id,create_time) VALUES (userId, i, NOW());
set i=i+1;
end while;
end;
call setUserRole(2,16,23);
转载请注明:谷谷点程序 » MySql 循环执行存储过程