mysql 存储过程、循环

CREATE PROCEDURE  questionProc()
BEGIN declare pgId int();
declare pGuid varchar();
 -- 定义游标卡尺
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();
上一篇:ElasticSearch(6)-结构化查询


下一篇:JavaScript for/in 语句 遍历数组内容