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();

 

posted @ 2019-03-15 21:25  骚年丶勿忘初心。  阅读(235)  评论(0编辑  收藏  举报