mysql双重循环示例
Posted 一曲秋殇
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql双重循环示例相关的知识,希望对你有一定的参考价值。
BEGIN DECLARE menu_id VARCHAR(36); DECLARE done INT DEFAULT FALSE; DECLARE cursor_rule CURSOR FOR SELECT s.id FROM d_menu_type s ; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN cursor_rule; l : LOOP FETCH cursor_rule INTO menu_id; IF done THEN LEAVE l; END IF; BEGIN DECLARE property_id VARCHAR(36); DECLARE done2 INT DEFAULT FALSE; DECLARE cursor_rule2 CURSOR FOR SELECT property_id FROM d_menu_property l WHERE l.menu_id=menu_id; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done2 = TRUE; OPEN cursor_rule2; l2 : LOOP FETCH cursor_rule2 INTO property_id; IF done2 THEN LEAVE l2; END IF; END LOOP; CLOSE cursor_rule2; END; END LOOP; CLOSE cursor_rule; END
以上是关于mysql双重循环示例的主要内容,如果未能解决你的问题,请参考以下文章