mysql 存储过程、循环
CREATE PROCEDURE questionProc() BEGIN declare pgId int(11); declare pGuid varchar(255);
-- 定义游标卡尺 declare done boolean DEFAULT TRUE; -- 获取数据到游标卡尺 DECLARE cur CURSOR FOR select id,qid from tb_question; -- 打开游标卡尺 OPEN cur;
-- 开始循环 WHILE done do FETCH cur INTO pgId,pGuid; update tb_question_item set question_id=pgId where qid= pGuid; end while; CLOSE cur; END; CALL questionProc();
文章属于个人工作备忘录,欢迎指正...