MySQL: LEAVE Statement
https://www.techonthenet.com/mysql/loops/leave.php
This MySQL tutorial explains how to use the LEAVE statement in MySQL with syntax and examples.
Description
In MySQL, the LEAVE statement is used when you want to exit a block of code identified by a label_name, such as a LOOP statement, WHILE statement, or REPEAT statement.
Syntax
The syntax for the LEAVE statement in MySQL is:
LEAVE label_name;
Parameters or Arguments
- label_name
- The name of the block of code (ie: LOOP, WHILE, REPEAT) to terminate.
Note
- You use the LEAVE statement to terminate a block of code, such as a LOOP statement, WHILE statement, or REPEAT statement that is identified by a label_name.
Example
Let's look at an example that shows how to use the LEAVE statement in MySQL:
DELIMITER // CREATE FUNCTION CalcIncome ( starting_value INT )
RETURNS INT BEGIN DECLARE income INT; SET income = 0; label1: LOOP
SET income = income + starting_value;
IF income < 3000 THEN
ITERATE label1;
END IF;
LEAVE label1;
END LOOP label1; RETURN income; END; // DELIMITER ;
In this LEAVE example, we have created a loop called label1 using the LOOP statement.
The ITERATE statement would cause the loop to repeat while income is less than 3000. Once income is greater than or equal to 3000, the LEAVE statement would terminate the LOOP.
MySQL: LEAVE Statement的更多相关文章
- MySql用statement实现DDL,DML,DQL的操作Demo
Demo1 Connection connection=null; Statement stmt=null; int result=-1; try { Class.forName("com. ...
- MyBatis项目快速搭建及MySQL一个Statement支持多条命令参数
一.简述 本文以笔记的形式,记录一个基本Mybatis项目的使用,方便后期项目使用到相关配置时直接复制使用. 二.项目结构 pom.xml中的依赖 <!-- https://mvnreposit ...
- MySQL 5.7 Replication 相关新功能说明
背景: MySQL5.7在主从复制上面相对之前版本多了一些新特性,包括多源复制.基于组提交的并行复制.在线修改Replication Filter.GTID增强.半同步复制增强等.因为都是和复制相关, ...
- java分享第十七天-03(封装操作mysql类)
JAVA操作mysql所需jar包:mysql-connector-java.jar代码: import java.sql.*; import java.util.ArrayList; import ...
- Mybatis拦截器 mysql load data local 内存流处理
Mybatis 拦截器不做解释了,用过的基本都知道,这里用load data local主要是应对大批量数据的处理,提高性能,也支持事务回滚,且不影响其他的DML操作,当然这个操作不要涉及到当前所lo ...
- LeetCode 177 Nth-Highest Salary mysql,取第n条数据,limit子句 难度:1
https://leetcode.com/problems/nth-highest-salary/ ATTENTION:limit 子句只能接受int常量,不能接受运算式 CREATE FUNCTIO ...
- Type mismatch: cannot convert from java.sql.PreparedStatement to com.mysql.jdbc.PreparedStatement
Connection.prepareStatement()函数出错,提示: Type mismatch: cannot convert from java.sql.PreparedStatement ...
- Raising Error Conditions with MySQL SIGNAL / RESIGNAL Statements
http://www.mysqltutorial.org/mysql-signal-resignal/ Summary: in this tutorial, you will learn how to ...
- 再次熟悉jdbc连接mysql
闲来无事想探究一下jdbc 1.首先准备工作.我们要下载jdbc驱动包mysql-connector-java-5.1.7-bin.jar.其他的暂时先不用,这个包的下载地址:http://pan.b ...
随机推荐
- Linux内核TCP/IP参数分析与调优
转载于:http://www.itxuexiwang.com/a/liunxjishu/2016/0225/167.html?1456482565 如下图展示的是TCP的三个阶段.1,TCP三次握手. ...
- JavaScript语法、对话框。分支语句
一.用法 其所在的位置有三块,1.head里面 2.body里面 3.</html>后 一般都写在</html>后 其用法为<script></scr ...
- EF架构~Cannot attach the file as database
回到目录 Cannot attach the file as database这个异常是在EF的code frist里经常出现的,解决方法很简单,只要重新启动一下V11实例即可. CMD> sq ...
- 你可能不知道console强大
写在前面 大家都有用过各种类型的浏览器,每种浏览器都有自己的特色,本人拙见,在我用过的浏览器当中,我是最喜欢Chrome的,因为它对于调试脚本及前端设计调试都有它比其它浏览器有过之而无不及的地方.可能 ...
- iptables基础命令详解
TCP/IP基本概念: TCP/IP将网络分为四层:应用层,传输层,网络层,链路层. 传输层:定义了两种通信协议,分别为TCP协议和UDP协议. TCP协议:TCP协议在传输 数据过程中会检查数据的完 ...
- session 学习
session机制是一种服务器端的机制,服务器使用一种类似于散列表的结构(也可能就是使用散列表)来保存信息. 当程式需要为某个客户端的请求创建一个session的时候,服务器首先检查这个客户端的请求里 ...
- Searching for a valid kernel header path... The path "" is not a valid path to the ***** kernel headers. Would you like to change it? [yes]
在centos 6.5安装vmtools时候,解压包,mount挂载后,安装pl过程中报 这个问题,半天没有解决,google 后发现这样就行了 I installed the kernel-deve ...
- Git Sophisticated Commands
Compare two branches: branch_1 and branch_2: git diff branch_1…branch_2 Merge specified files of one ...
- struts之动态方法调用改变表单action属性
一.动态方法调用(DMI:Dynamic Method Invocation) ⒈struts2中同样提供了这个包含多个逻辑业处理的Action,这样就可以在一个Action中进行多个业务逻辑处理 ...
- Android线程之Looper
之前已经为大家奉献了关于Handler和Message的使用,本篇我们来了解一下Handler内部的具体使用,本篇主要探讨Looper的在处理Handler的消息机制中起的重要作用,我们知道我们在子线 ...