mysql while 循环

DELIMITER $$
CREATE PROCEDURE pro_insert(IN maxNum INT) 
BEGIN 
    DECLARE i INT DEFAULT(1);
    
    while i<=maxNum DO
        INSERT INTO employees (first_name ,last_name) VALUES ("z",CONCAT("sc",i));
        SET i=i+1;
        
        END WHILE;
END $$

DELIMITER ;


CALL pro_insert(20);
posted @ 2021-07-21 09:24  雪竹子  阅读(747)  评论(0编辑  收藏  举报