mysql的循环语句问题
问题描述
要多次的执行一个select操作,就想着用循环来实现,在网上查了一些内容,显示的做法都是差不多的,就是总是提示语言错误,很是郁闷,各位大侠帮忙看看,要怎么改才可以。mysql数据库、navicat客户端。mysql循环的操作语句:
procedure pro10()begindeclare i int; set i=0; while i<5 do select * from gamechannel where status=i GROUP BY gameId ; set i=i+1; end while;end;
错误信息:[SQL] procedure pro10()begindeclare i int;[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’procedure pro10()begindeclare i int’ at line 1
问题解答
回答1:你这是再写存储过程吗?1.创建存储过程DELIMITER $$create procedure pro10()begindeclare i int; set i=0; while i<5 do
select * from gamechannel where status=i GROUP BY gameId ; set i=i+1;
end while;end;$$
2.调用call pro10()
相关文章:
1. sass - gem install compass 使用淘宝 Ruby 安装失败,出现 4042. javascript - js 对中文进行MD5加密和python结果不一样。3. mysql里的大表用mycat做水平拆分,是不是要先手动分好,再配置mycat4. window下mysql中文乱码怎么解决??5. 为啥不用HBuilder?6. python - (初学者)代码运行不起来,求指导,谢谢!7. javascript - h5上的手机号默认没有识别8. python - 获取到的数据生成新的mysql表9. python的文件读写问题?10. 为什么python中实例检查推荐使用isinstance而不是type?
