日期:2014-05-16 浏览次数:20808 次
DELIMITER $$ CREATE /*mysql嵌套if演示*/ PROCEDURE `pfmalls`.`pfm_proc_test` ( a INT, b INT ) BEGIN DECLARE c INT; IF a IS NULL THEN SET a = 0; ELSEIF a > 10 THEN IF a < 15 THEN SET a = 20; ELSEIF a > 10 THEN SET a = 10; END IF; ELSE #严重注意 else后面不用跟then IF a > 30 THEN SET a = 30; ELSE SET a = 40; END IF; #set a = 30; END IF; IF b IS NULL THEN SET b = 0; END IF; SET c = a + b; SELECT c AS SUM; END$$ DELIMITER ; /*执行: call(10,20);*/?