以下是MySQL中END IF语句的语法
IF yourCondition THEN yourStatement ELSE yourStatement END IF
这是创建存储过程时END IF语句的演示
mysql> DELIMITER // mysql> CREATE PROCEDURE Sp_Test( IN value INT ) - > BEGIN - > IF value < 10 THEN - > select 'Your value is less than 10'; - > ELSE - > select 'Your value is greater than 10'; - > END IF; - > - > END // mysql> DELIMITER ;
借助CALL命令调用存储过程。
语法如下
CALL yourStoredProcedureName();
现在您可以调用上述存储过程,如下所示
mysql> CALL Sp_Test(15);
以下是输出
+-------------------------------+ | Your value is greater than 10 | +-------------------------------+ | Your value is greater than 10 | +-------------------------------+ 1 row in set (0.00 sec)