MySQL Loop Branch Syntax

Source: Internet
Author: User

---restore content starts---

Loop loop

label:loop    statement_list    IFthen        LEAVE label;      END IF  END LOOP label;
View Code

Repeat cycle

REPEAT     END REPEAT;
View Code

While loop

 while search_condition do    statement_listENDwhile;
View Code

IF ... Else Branch judgment

IF  Then     statement_listELSE    statement_listENDIF;
View Code

IF ... ELSEIF ... Else Branch judgment

IF  Then          then statement_list ELSE statement_list END      IF;
View Code

Cast branch judgment

 Case Case_value      when  Then         statement_list    ELSE        statement_listENDcase;
View Code

Create a stored procedure (PROCEDURE)

Create PROCEDURE procedure_name ([in| Out| INOUT]  param_name param_type,...) BEGIN     statement_listEND
View Code

Delete a stored procedure (PROCEDURE)

DROP PROCEDURE procedure_name
View Code

View stored Procedures (PROCEDURE)

SELECT    *  from     MySQL. proc WHERE  = ' PROCEDURE '     
View Code

Creating Functions (function)

CREATE FUNCTION function_name (param_name param_type,...) RETURNS Return_type BEGIN     statement_listEND
View Code

Delete Functions (function)

DROP FUNCTION IF EXISTS function_name
View Code

View functions (function)

SELECT    *  from     MySQL. proc WHERE  = ' FUNCTION '     
View Code

Defining variable Assignment values

-- function or stored procedure (PROCEDURE) defines variables and assigns values    -- definition    DECLARE DEFAULT default_value;     -- Assign Value    SET = New_value;     -- Assigning in a select query    SELECT variable_name:=col_name;
View Code

Detailed description of defining variable assignments: https://www.cnblogs.com/EasonJim/p/7966918.html

About dynamic MySQL statements: http://blog.itpub.net/29773961/viewspace-1852824/

MySQL Loop Branch Syntax

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.