日期:2014-05-16 浏览次数:20813 次
IF search_condition THEN statement_list [ELSEIF search_condition THEN statement_list] ... [ELSE statement_list] END IF
DELIMITER$$ DROP PROCEDURE IF EXISTS pro_if$$ CREATE PROCEDURE pro_if( i INT ) BEGIN IF i < 60 THEN SELECT '需继续努力,争取过线!' AS result; ELSEIF i < 85 THEN SELECT '再努力点,争取达优!' AS result; ELSE SELECT '不错哦,恭喜,恭喜!' AS result; END IF; END$$
CASE case_value WHEN when_value THEN statement_list [WHEN when_value THEN statement_list] ... [ELSE statement_list] END CASE
CASE WHEN search_condition THEN statement_list [WHEN search_condition THEN statement_list] ... [ELSE statement_list] END CASE
DELIMITER$$ DROP PROCEDURE IF EXISTS pro_case$$ CREATE PROCEDURE pro_case( i INT ) BEGIN CASE i WHEN 1 THEN SELECT 'you male!' AS result; WHEN 0 THEN SELECT 'you female!' AS result; ELSE SELECT 'third sex!' AS result; END CASE; END$$