Mysql SQL stored procedure flow control if statement usage

Source: Internet
Author: User

If conditions are determined to meet different conditions and perform different operations, we only need to learn programming and know the role of if. Let's take a look at how to use if in the mysql stored procedure.

Today, let's talk aboutMysql tutorial SQL stored procedure flow control if statement usageWith the instance tutorial

If statement

If implementationCondition judgmentTo perform different operations according to different conditions, we only need to know the function of if when learning programming. Let's take a look at how to use if in the mysql stored procedure.

If contion then list

[Elseif condition then list] ......

[Else list]

End if

This looks like the conditions in the asp tutorial, but when elseif is used, it is like if in the php tutorial, but no matter what it is like, we know its usage, let's take a look at the example of an if statement.

Mysql> create procedure ifprod ()

-> Begin

-> Set @ x = 0;

-> Ins: loop;

-> Set @ x = @ x + 1;

If @ x = 100 then

Leave ins;

End if

Insert into actor (firestname) values ('www. bKjia. c0m ');

End loop ins;

End;

-> $

Query OK, 0 rows affected (0.00 sec );

A simple example is used to demonstrate the mysql SQL stored procedure.Process control ifStatement usage

The original tutorials on this site are reproduced and indicated by www. bKjia. c0m/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.