如题
解决方案 »
- mysql同步error(Slave_IO_Running: )error connecting to master
- 关于内网mysql数据服务器 与 外网数据库同步的问题
- 一个简单的 mysql 触发器
- C++连接mysql 执行 load data file 问题
- 添加当前时间报错
- mysql 有没有类似于oracle的comment on之类的语法?
- 把一个表的一列 copy 到另一个表的某列,按名字对应copy
- 用纯C对mysql存取blob,分不够再加
- 关于创建数据库的问题?
- java中对mysql执行update语句问题?在线等待。。。
- mysql 的表结构有几种
- 多线程中使用mysql的c api是安全的吗??
BEGIN
DECLARE cnt int;
declare cnt2 int;
declare cnt3 int;
declare i int;
select count(*) from tbl into cnt;
select ceil(cnt/100) into cnt2;
set i=0;
loop1:loop
set i = i + 1;
select 100*i into cnt3;
if i > cnt2 then
leave loop1;
end if;
select * from tb1 limit cnt3,1;
end loop loop1;
END$$DELIMITER ;
贴出正确的:
DELIMITER $$DROP PROCEDURE IF EXISTS `test`.`sp_sum`$$CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_gehang`()
BEGIN
DECLARE cnt int;
declare cnt2 int;
-- declare cnt3 int;
declare i int;
select count(*) from song into cnt;
select ceil(cnt/100) into cnt2;
set i=0;
loop1:loop
set i = i + 1;
-- select 2*i into cnt3;
if i > cnt2 then
leave loop1;
end if;
set @smt = 'select * from song limit ?,1;';
prepare s1 from @smt;
-- set @cnt3 = 2*i;
set @cnt3 = 100*i;
execute s1 using @cnt3;
deallocate prepare s1 ;
end loop loop1;
END$$DELIMITER ;