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 ...
随机推荐
- IOS Animation-CABasicAnimation、CAKeyframeAnimation详解&区别&联系
1.先看看网上流传的他们的继承图: 从上面可以看出CABasicAnimation与CAKeyframeAnimation都继承于CAPropertyAnimation.而CAPropertyAnim ...
- 深入了解Java程序执行顺序
Java中main方法,静态,非静态的执行顺序详解 Java程序运行时,第一件事情就是试图访问main方法,因为main相等于程序的入口,如果没有main方法,程序将无法启动,main方法更是占一个独 ...
- iOS开发备忘录:属性列表文件数据持久化
属性列表文件是一种XML文件,Foundation框架中的数组和字典等都可以于属性列表文件相互转换. NSArray类常用读写属性列表文件的方法: +arrayWithContentsOfFile:类 ...
- phpstudy80端口被占用时的解决方案
1.适合人群? 之前笔记本单独安装过Apache.php.mysql环境,但是后期想用集成开发环境phpstudy的,安装完phpstudy后(之前的单独环境依然存在),发现启动时,总是显示80端口被 ...
- 修复发生“由于数据移动,未能继续以 NOLOCK 方式扫描”错误的数据库
最近在系统运行中发现了一个错误,错误信息如下: 错误信息:查询A201412C20568单证信息错误 ---> System.Data.OleDb.OleDbException: 由于数据移动, ...
- CSS层模型
参考:慕课网 点此可进 如何让html元素在网页中精确定位,就像图像软件PhotoShop中的图层一样可以对每个图层能够精确定位操作.CSS定义了一组定位(positioning)属性来支持层布局模型 ...
- Web前端优化最佳实践及工具集锦
Web前端优化最佳实践及工具集锦 发表于2013-09-23 19:47| 21315次阅读| 来源Googe & Yahoo| 118 条评论| 作者王果 编译 Web优化Google雅虎P ...
- windows下zookeeper伪集群搭建
下载 http://www.apache.org/dyn/closer.cgi/zookeeper/ 解压 D:\Java\soft\zookeeper-3.4.6 伪集群 1.在 \zookeepe ...
- js cookie存储方法
/*! * jQuery Cookie Plugin v1.4.0 * https://github.com/carhartl/jquery-cookie * * Copyright 2013 Kla ...
- 手机端web学习基础--from慕课网
web知识零零散散的知道一些,但总感觉不够系统,遇到问题不知道如何解决,因此特此来系统的学习一下web前端的知识.从慕课网的web基础看起.下面学习http://www.imooc.com/learn ...