mysql存储过程之一些杂碎知识
2017-11-01 22:08
393 查看
XML Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1、在存储程序中使用非 SELECT SQL 语句(可以向表中添加/修改/删除数据) create table t1(id int ,name varchar(20)); create procedure insert_data(in count int) begin declare i int default 0; repeat set i=i+1; insert into t1(id,name) values(i,concat('name-',i)); until i=10 end repeat; end$$ 2、把表中的数据读入本地变量(使用select-into语法结构) create procedure use_select_into() begin declare count int default 0; select count(1) into count from t1; select concat('==>',count); end$$ create procedure use_select_into2() begin declare row_id int default 0; declare row_name varchar(20) default ''; declare i int default 0; while i<=10 do set i=i+1; select id,name into row_id,row_name from t1 where id = i; select concat('[',i,'] id=',row_id,' name=',row_name); end while; end$$ |
相关文章推荐
- mysql写存储过程的一些注意事项以及mysql的一些函数
- MySQL 存储过程的那点知识
- Mysql_知识总结03(级联操作+多表查询【左外连接查询*重点掌握】+数据库的存储过程)
- 关于一些简单的存储过程知识
- Mysql存储过程入门知识
- Mysql_知识总结04(存储过程的建立、调用)
- MySql存储过程—1、SQL存储过程的基础知识
- Mysql存储过程知识,案例
- [置顶] Mysql存储过程入门知识
- Mysql中存储过程中的一些常见用法总结
- MySql存储过程—1、SQL存储过程的基础知识
- MySQL存储过程和函数(1) - 基础知识
- ORACLE 有关存储过程的一些基础知识
- MySql存储过程学习知识小结
- MySQL知识总结(三)存储过程
- MySql存储过程—1、SQL存储过程的基础知识
- MySQL存储过程中一些基本的异常处理教程
- MYSQL 存储过程1、SQL存储过程的基础知识
- mysql存储过程中常用的一些功能性语句
- 投票系统的Mysql存储过程遇到的一些问题.