双重循环插入
DELIMITER ;; CREATE PROCEDURE test_insert() BEGIN DECLARE a INT DEFAULT 1; DECLARE b TINYINT DEFAULT 1; WHILE (a <= 100) DO -- repeat SET a = a + 1; -- select a; WHILE (b <=20) DO insert into school_sp_mj(school_id,mojor_id,status) values(a,b,1); SET b = b + 1; -- select b; END WHILE; SET b = 1; -- select a; -- until a >= i_PlayerCount -- end repeat; END WHILE; commit; END;; CALL test_insert();
单循环插入
DELIMITER ;; CREATE PROCEDURE test_insert() BEGIN DECLARE y TINYINT DEFAULT 1; WHILE y<20 DO insert into school_sp_mj(school_id,mojor_id,status) values(1,y,1); SET y=y+1; END WHILE ; commit; END;; CALL test_insert();