12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
mysql数据库 时间:2024-12-03 10:28:06
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
mysql的for循环语句怎么写MySQL是不支持for循环语句的,MySQL支持while循环、repeat循环、loop循环1.while循环delimiter //#定义标识符为双斜杠drop procedure if exists tes
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
mysql的for循环语句怎么写
MySQL是不支持for循环语句的,MySQL支持while循环、repeat循环、loop循环
1.while循环
delimiter //#定义标识符为双斜杠drop procedure if exists test;#如果存在test存储过程则删除create procedure test() #创建无参存储过程,名称为testbegindeclare i int;#申明变量set i = 0;#变量赋值while i < 10 do #结束循环的条件: 当i大于10时跳出while循环insert into test values (i);#往test表添加数据set i = i + 1;#循环一次,i加一end while;#结束while循环select * from test; #查看test表数据end//#结束定义语句call test();#调用存储过程
2.repeat循环
delimiter //#定义标识符为双斜杠drop procedure if exists test;#如果存在test存储过程则删除create procedure test() #创建无参存储过程,名称为testbegindeclare i int;#申明变量set i = 0;#变量赋值repeatinsert into test values (i);#往test表添加数据set i = i + 1;#循环一次,i加一until i > 10 end repeat;#结束循环的条件: 当i大于10时跳出repeat循环select * from test; #查看test表数据end//#结束定义语句call test();#调用存储过程
3.loop循环
delimiter //#定义标识符为双斜杠drop procedure if exists test;#如果存在test存储过程则删除create procedure test() #创建无参存储过程,名称为testbegindeclare i int;#申明变量set i = 0;#变量赋值lp : loop #lp为循环体名,可随意 loop为关键字insert into test values (i);#往test表添加数据set i = i + 1;#循环一次,i加一if i > 10 then#结束循环的条件: 当i大于10时跳出loop循环leave lp;end if; end loop;select * from test; #查看test表数据end//#结束定义语句call test();#调用存储过程
MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一。MySQL是一种关系型数据库管理系统,关系数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19