mysql存储过程while循环搭配if elseif选择条件

drop procedure if exists myProc;
delimiter $$
CREATE PROCEDURE myProc(in segNum int(11))
 BEGIN
  DECLARE j int;
   DECLARE i int;
   SET i=1;
    SET j=segNum;
     IF i > 0 THEN
   loop1: WHILE j>0 AND i<=j DO
   IF i = 1 THEN
    IF MOD(i,2)<>0 THEN
     SELECT CONCAT(i," is an odd number");
      END IF;
    


    ELSEIF MOD(i,2)=0 THEN 
     SELECT CONCAT(i," is an odd number");
     
     END IF;
    
    
    SET i=i+1;
   END WHILE loop1;
  
     END IF;
    
 END$$
delimiter;
call myProc(11);

你可能感兴趣的:(mysql)