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. PHP单例模式2. PHP中的$this代表当前的类还是方法?3. win下面的cmder中的vim . 中文乱码. 试了百度上的各种解决方式.. 还是没弄好4. javascript - H5页面无缝轮播5. Eclipse IDE的Java构建路径已更改我选择哪一个?6. javascript - 有没有iOS微信中可以在背景播放视频的方法?7. node.js - 为什么微信的消息MsgId出现重复了,无法排重了。。8. javascript - 在nodejs或者JS中怎么计算图片的MD5哈希值9. 前端 - CSS 真的有复用性和扩展性可言吗?我感觉我已经完全不会写代码了.....10. eclipse - 使用velocity时报java.lang.NoClassDefFoundError,是否少了什么包?
