drop function if exists repeatfunction // create function repeatfunction() returns varchar(50) begin declare l_repeat_count, l_count_2 int default 0; rep1: repeat set l_repeat_count = l_repeat_count + 1; if l_repeat_count > 5 and l_repeat_count < 9 then iterate rep1; end if; set l_count_2 = l_count_2 + 1; until l_repeat_count = 10 end repeat rep1; return concat('We looped ',l_repeat_count,' times, but we only counted to ',l_count_2); end //