Mysql储存过程3:if语句
Posted FireC@t @ Perl6
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql储存过程3:if语句相关的知识,希望对你有一定的参考价值。
--if/else语句 if 条件 then SQL语句 else SQL语句
elseif
SQL语句 end if; create procedure test1( number int ) begin if number > 10 then select user(); else select ‘please input a number > 10‘; end if; end$
mysql> create procedure test1( -> number int -> ) -> begin -> if number > 10 then -> select user(); -> else -> select ‘please input a number > 10‘; -> end if; -> end$ Query OK, 0 rows affected (0.00 sec) mysql> call test1()$ ERROR 1318 (42000): Incorrect number of arguments for PROCEDURE test.test1; expected 1, got 0 mysql> call test1(11)$ +----------------+ | user() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.01 sec) mysql> call test1(1)$ +----------------------------+ | please input a number > 10 | +----------------------------+ | please input a number > 10 | +----------------------------+ 1 row in set (0.00 sec) Query OK, 0 rows affected (0.01 sec) mysql>
以上是关于Mysql储存过程3:if语句的主要内容,如果未能解决你的问题,请参考以下文章