Process control

One 、 Conditional statements

if Statement instance :

delimiter //
CREATE PROCEDURE proc_if ()
BEGIN declare i int default 0;
if i = 1 THEN
SELECT 1;
ELSEIF i = 2 THEN
SELECT 2;
ELSE
SELECT 7;
END IF; END //
delimiter ;

Two 、 Loop statement

while Instance of statement :

delimiter //
CREATE PROCEDURE proc_while ()
BEGIN DECLARE num INT ;
SET num = 0 ;
WHILE num < 10 DO
SELECT
num ;
SET num = num + 1 ;
END WHILE ; END //
delimiter ;

repeate Examples of loop statements :

delimiter //
CREATE PROCEDURE proc_repeat ()
BEGIN DECLARE i INT ;
SET i = 0 ;
repeat
select i;
set i = i + 1;
until i >= 5
end repeat; END //
delimiter ;

loop Example :

BEGIN
declare i int default 0;
loop_label: loop set i=i+1;
if i<8 then
iterate loop_label;
end if;
if i>=10 then
leave loop_label;
end if;
select i;
end loop loop_label; END

attach :Mysql Basic usage

One 、【Mysql View of basic usage

Two 、【Mysql Trigger of basic usage

3、 ... and 、【Mysql Business of basic usage

Four 、【Mysql Basic usage of stored procedure

5、 ... and 、【Mysql Function of basic usage

6、 ... and 、【Mysql Process control of basic usage

Knowledge point :Mysql Basic usage of process control more related articles

  1. mysql Stored procedures and common process control

    /* The code is created by a program called "p4" And set s1,s2,s3 Two int Type one varchar Type parameter , It can also be other data types , Inside created x1,x2 Two variables DELIMITER yes ...

  2. Knowledge point :Mysql Basic usage of stored procedure

    stored procedure One . Introduce Stored procedures contain a series of executable sql sentence , Stored procedures are stored in MySQL in , By calling its name, you can execute its internal heap sql Advantages of using stored procedures : Used to replace program written SQL sentence , Realize the program and sql ...

  3. Knowledge point :Mysql View of basic usage

    View The view is a virtual table ( It's not real ), Its essence is [ according to SQL Statement to get a dynamic data set , And name it ], Users only need to use [ name ] You can get the result set , You can use the result set as a table . Using the view, we can put the temporary information in the query process ...

  4. Knowledge point :Mysql Function of basic usage

    function MySQL Many built-in functions are provided in for example : sql Built in functions : One . Mathematical functions ROUND(x,y) Returns the parameter x The rounding of is y A decimal value RAND() return 0 To 1 The random value in , By providing a parameter ( Kind of ...

  5. Knowledge point :Mysql Trigger of basic usage

    trigger Using triggers, you can customize the user's behavior on the table [ increase . Delete . Change ] Before and after the operation Be careful : No query One . Create trigger Trigger basic syntax : # Before insertion CREATE TRIGGER tri_before_insert_ ...

  6. Knowledge point :Mysql Business of basic usage

    Business The transaction is used to put more than one of certain operations SQL As an atomic operation , Once something goes wrong , You can roll back to the original state , So as to ensure the integrity of database data . Transaction instance : create table user( id int primar ...

  7. 034 01 Android Zero Basics 01 Java Basic grammar 04 Java The selection structure of process control 01 Process Control Overview

    034 01 Android Zero Basics 01 Java Basic grammar 04 Java The selection structure of process control 01 Process Control Overview Knowledge of this article :Java Understanding of process control related concepts in A brief introduction to the structure of three flow control statements The order ...

  8. MySQL User defined function usage details - Composite structure custom variables / Process control

    Custom function (user-defined function UDF) Just use an elephant ABS() or CONCAT() This kind of inherent ( The built-in ) Function to expand MySQL. therefore UDF It's right MySQL One of the functions ...

  9. 【mysql Special topic of programming ①】 Process control and other Syntax

    Process control and built-in functions , Generally used in select Of field Field , Or in functions , stored procedure , Trigger ; If used in select It's going to go with query Coming out row To iterate implicitly ; Comments and statement terminators Statement Terminator By default, there are two ...

Random recommendation

  1. CRL Quick development framework series 12 (MongoDB Support )

    The catalogue of this series CRL Quick development framework series tutorial 1 (Code First Datasheets don't need to care anymore ) CRL Quick development framework Series 2 ( be based on Lambda Expression query ) CRL Quick development framework series 3 ( Update data ) CRL Quick development box ...

  2. paper 42 : Wavelet transform of image

    I just have a very simple understanding about wavelet transform . But wavelet transform can be combined with Fourier transform to understand . Fourier transform uses a series of sine and cosine functions with different frequencies to decompose the original function , After transformation, the coefficients of the original function at different frequencies of sine and cosine are obtained . Wavelet transform uses a series of ...

  3. Please elaborate on calling Activity What are the ways , And write the relevant Java Code

    Please elaborate on calling Activity What are the ways , And write the relevant Java Code . answer : You can call... In two ways Activity: Show calls and implicit calls . The display call directly specifies Activity, The code is as follows : Intent int ...

  4. 【iOS】Mapkit Use : The map shows 、 location 、 A pin 、 Bubbles, etc

    from :http://blog.csdn.net/dolacmeng/article/details/46594839 I used to do projects with Gaud maps SDK, You need to register an account and AppID, Then download SDK Integrate into the project , ...

  5. Selenium The orientation of learning elements in automated testing

    This is a question that I am often asked , It's also a question I hate to answer , Because to answer this question, you need to know the context . What kind of elements , What properties are there , Whether there are nested forms , What positioning methods have been tried ... And few questioners can elaborate on that in advance . Where? ...

  6. 3. Keyboard entry 10 Number , Put it in the array ,(1) Remove the values greater than in the array 10 Number of numbers (2) Write the numbers in the array to a local file number.txt in

    package cn.it.text; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; ...

  7. Asp.Net MVC+EF+ Three layer architecture

    Architecture diagram : Database used : A company employee information sheet , Test data Solution project design : 1. Create a new blank solution named Company 2. Under this solution , New solution folder (UI,BLL,DAL,Model) ...

  8. Vue.js Example :GitHub Submit (watch data ,created hook ,filters Filter ); Grid components ( function :1. retrieval ,2 Sort );

    GitHub Submit codePen:   https://codepen.io/chentianwei411/pen/wEVPZo Be careful : Frequent cases , It could be limited . a key : Form input binding , The use of radio buttons ...

  9. c++ Brush problem (37/100) Pen test 2

    4 Problem 2 Hours , It's another , But this one is more difficult , But the second one shouldn't be , It's the careless examination that leads to the failure subject 1: Given a string , Please recode the string , Replace consecutive characters with “ The number of consecutive occurrences + character ”. Like strings AAAABCC ...

  10. Unhandled exception :System.Net.Sockets.SocketException: Made an attempt to access the socket in a way that the access permission is not allowed

    Report errors : Unhandled exception :System.Net.Sockets.SocketException: Made an attempt to access the socket in a way that the access permission is not allowed → Try to " Administrator status " Run the program , ...