MySQL control statements

Source: Internet
Author: User

14.6.5.1 Case Syntax

14.6.5.2 IF Syntax

14.6.5.3 Iterate Syntax

14.6.5.4 LEAVE Syntax

14.6.5.5 LOOP Syntax

14.6.5.6 REPEAT Syntax

14.6.5.7 RETURN Syntax

14.6.5.8 while Syntax

Case USAGE:

Two ways to use:

IF usage:

Looping statements: Iterate Syntax

Iterate is used only in loop,repeat,while; iterate, refers to the next cycle to begin.

14.6.5.4 LEAVE Syntax

LEAVE label, exit the control flow.

LEAVECan be used within BEGIN ... END or loop constructs ( LOOP , REPEAT , WHILE ).

Loop,

REPEAT,

Delimiter//
CREATE PROCEDURE dorepeat (p1 int)
Begin
Set @x=0;
Repeat
Set @[email protected]+1;
Until @x>p1
End repeat;
Select @x;
End//
Call Dorepeat (1000);

While,

CREATE PROCEDURE dowhile () BEGIN  DECLARE v1 INT DEFAULT 5;  While v1 > 0 do    ...    SET v1 = v1-1;  END while; END;

MySQL control statements

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.