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

Mysql stored procedure case statement syntax and example tutorial

黄舟
Release: 2016-12-24 17:52:07
Original
1248 people have browsed it

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!


Related labels:
Statement of this Website
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
Latest Issues
Using Case to subtract price in Mysql
From 1970-01-01 08:00:00
0
0
0
Laravel doesn't read POST request with FormData
From 1970-01-01 08:00:00
0
0
0
Optimize the use of CASE statements in MySQL
From 1970-01-01 08:00:00
0
0
0
php - How to optimize this sql?
From 1970-01-01 08:00:00
0
0
0
MySQL: How to use CASE with ORDER BY clause
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template