在MySQL中是否在存储过程中实现?
要实现if-else,语法如下-
if yourCondition then
yourStatement1;
else
yourStatement2;
end if ;要了解存储过程中if-else的上述概念,让我们创建一个存储过程-
mysql> delimiter //
mysql> create procedure If_else_stored_demo(value int)
begin
if value > 1000 then
select "your value is greater than 1000";
else
select "your value is less than or equal to 1000";
end if ;
end
//
mysql> delimiter ;现在您可以使用调用命令来调用存储过程-
mysql> call If_else_stored_demo(500);
这将产生以下输出-
+------------------------------------------+ | your value is less than or equal to 1000 | +------------------------------------------+ | your value is less than or equal to 1000 | +------------------------------------------+ 1 row in set (0.00 sec)
热门推荐
1 十月简短祝福语
10 下雪宝宝生日祝福语简短
11 带清的简短祝福语
12 祝球员赛前祝福语简短
13 妈妈祝福语简短16字
14 送外卖祝福语大全简短
15 美好的成语祝福语简短
16 祝寿时祝福语简短精辟
17 18岁祝福语搞笑简短
18 给干爸过年祝福语简短