MySQL stored procedure Case statement syntax and example tutorial

Source: Internet
Author: User
Tags case statement mysql tutorial

And then we're going to talk about the MySQL Tutorial stored procedure Case statement syntax and example tutorial Oh, home page let's look at a brief description of the case statement, and then illustrate the specific usage of the cases with an example.

Case statement.

A case statement is a bit 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, if most of the statements can be done in case, of course, all the cases of the example can be completed, let's look at an instance of the sample tutorial .

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;

All right, about case syntax and instance usage we've all given an example of how to view articles if you don't understand them.

Site original article reproduced friend trouble plus the site address, original is not easy to thank,

Reprint Address www.111cn.net/database/database.html

Related Article

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.