Mysql stored procedure case statement syntax and example tutorial

Source: Internet
Author: User

Next we will talk about the mysql stored procedure case statement syntax and instance tutorial. on the home page, let's take a look at the simple description of the case statement, and then explain the specific usage of the case with examples.

Next we will talk aboutMysql tutorial stored procedure case statement syntax and example tutorialOh, let's take a look at the simple description of the case statement on the homepage, and then use the example description.Case.

Case statement.

The case statement is more complex than the if statement. 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 of the if statements can be completed using case. Of course, all case statements can be completed using case. Let's take a look at the 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

@ XbKjia. c0m = @ xbKjia. c0m + 'www. bKjia. c0m ';

End case;

Let's take an example of the case syntax and instance usage. If you do not understand it, you can refer to the relevant articles.

The original Article reposted on this site may be difficult. Thanks,

Reprinted at www. bKjia. c0m/database/database.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.