当前位置:网站首页>What are the circular statements of MySQL
What are the circular statements of MySQL
2022-06-29 04:22:00 【Yisu cloud】
MySQL What are the loop statements of
This article “MySQL What are the loop statements of ” Most people don't quite understand the knowledge points of the article , So I made up the following summary for you , Detailed content , The steps are clear , It has certain reference value , I hope you can gain something after reading this article , Let's take a look at this article “MySQL What are the loop statements of ” Article bar .
mysql There are three common ways of cycling :while、repeat and loop loop . There is another kind. goto, It is not recommended to use .

1.while loop
-- Set up mysql The separator is //, That means , When it comes to the next one // when , Overall execution SQL sentence DELIMITER // DROP PROCEDURE if EXISTS ‘test’; # If there is test Stored procedures are deleted CREATE procedure test() # Create a parameterless stored procedure , The name is testBEGIN DECLARE i INT; # Declare variables SET i = 0; # Variable assignment WHILE i# Conditions for ending the cycle : When i Greater than 5 Jump out when while loop INSERT INTO test VALUES(i+11,'test','20'); # Go to test Table add data SET i = i+1; # Cycle time ,i Add 1END WHILE; # end while loop SELECT * FROM test; # see test Table data END // # End definition statement CALL test(); # Calling stored procedure DELIMITER ; # Reset the separator to ;
2.repeat loop
DELIMITER // DROP PROCEDURE IF EXISTS test; CREATE PROCEDURE test() BEGIN DECLARE i INT; SET i = 0; REPEAT INSERT INTO test VALUES(i+11,'test','20'); # Go to test Table add data SET i = i + 1; # Cycle time ,i Add one UNTIL i > 10 END REPEAT; # Conditions for ending the cycle : When i Greater than 10 Jump out when repeat loop SELECT * FROM test; END // CALL test(); DELIMITER ;
3.loop loop
DELIMITER // DROP PROCEDURE IF EXISTS test; CREATE PROCEDURE test() BEGIN DECLARE i INT; SET i = 0; lp : LOOP # lp Is the body name of the loop , Feel free to loop Keyword INSERT INTO test VALUES(i+11,'test','20'); # Go to test Table add data SET i = i + 1; # Cycle time ,i Add one IF i > 10 THEN # Conditions for ending the cycle : When i Greater than 10 Jump out when loop loop LEAVE lp; END IF; END LOOP; SELECT * FROM test; END // CALL test(); DELIMITER ;
That's about “MySQL What are the loop statements of ” The content of this article , I believe we all have a certain understanding , I hope the content shared by Xiaobian will be helpful to you , If you want to know more about it , Please pay attention to the Yisu cloud industry information channel .
边栏推荐
- ECS 四 Sync Point、Write Group、Version Number
- Hot renewal process
- Establishment of small and medium-sized enterprise network
- 1015 theory of virtue and talent
- NotImplementedError: Could not run torchvision::nms
- Redis 缓存穿透、缓存击穿、缓存雪崩
- Anaconda's own Spyder editor starts with an error
- Multi machine LAN office artifact rustdesk use push!!!
- C language -- branch structure
- JVM_ 16_ Garbage collector
猜你喜欢

Redis cache penetration, cache breakdown, cache avalanche

Wi-Fi 7 来啦,它到底有多强?

女程序员晒出5月的工资条:工资是高,但是真累,网友评论炸锅了

访问数据库时出现错误

HCIE-Security Day41:理论学习:信息收集与网络探测

树莓派用VNC Viewer方式远程连接

SQL two columns become multi row filter display

JDBC learning

yolox出现 RuntimeError: DataLoader worker (pid(s) 17724, 1364, 18928) exited unexpectedly

选对学校,专科也能进华为~早知道就好了
随机推荐
SqlServer如何查询除去整列字段为null的结果
如何创建 robots.txt 文件?
CDC2.2.1还不支持postgresql14.1么?基于pgbouncer连接方式下,以5433
SQL 数据记录如何上下行合并
sql两列变为多行过滤显示
Idea modifying JVM memory
1019 数字黑洞
Remediation for Unsafe Cryptographic Encryption
Seattention channel attention mechanism
How to create a subtype like relationship between two generic classes when the classes are generic related
Open source demo| you draw and I guess -- make your life more interesting
Webassembly learning - dynamic linking
【新功能】Ambire 钱包集成了 Metis 网络
Redis cache penetration, cache breakdown, cache avalanche
String differences between different creation methods
Technology: how to design zkvm circuit
moudo网络库剖析
1017 A除以B分
Cloud native weekly | grafana 9 was officially released; The Chinese version of cloud native vocabulary is now online
c语言 --- 分支结构