Home >Database >Mysql Tutorial >Mysql stored procedure case statement syntax and example tutorial

Mysql stored procedure case statement syntax and example tutorial

黄舟
黄舟Original
2016-12-24 17:52:071231browse

case statement. The

case statement is more complicated than if, and it can construct more complex conditions.

Case condtion

WHEN whenvalue THEN statlist

[when value then statmentlist]

[else statmentlist]

end case

or:

case

when scontion then stlist

[when sconteiont then statlist]

[else statlst]

end case
In programming, most if statements can be completed using case. Of course, all the methods of case can be completed by if. Let's take a look at an example tutorial of case.

case

when iid=2 then

set @x=@x1+dcount;

else

set @x2 = @x2+ dcount ;

end case;

or

case id

when 2 then

@x1 = @x1 + 5;

else

@x111cn.net = @x111cn.net+ 'www.111cn.net';

end case;

The above is the mysql stored procedure case statement syntax and examples For the content of the tutorial, please pay attention to the PHP Chinese website (www.php.cn) for more related content!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn