Maison > Questions et réponses > le corps du texte
mysql的存储过程,如果实现递增
比如 下面的sql
DELIMITER //
drop procedure if exists p_loop//
CREATE PROCEDURE p_loop()
begin
declare v INT;
set v = 0;
loop_label : LOOP
UPDATE project_info SET project_code = (select concat('1','1',100+v)from dual) where dept_id = 1;
set v = v+1;
select v from dual;
if v >= 33 then
leave loop_label;
end if;
end loop;
end;
CALL p_loop();
我想让v自增到33,如何实现?