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. PC 手机兼容的 编辑器2. 编辑管理员信息时,为什么没有修改过的内容会为空?3. angular.js - Angular 像这种重复判断的表达式 有什么好的解决办法吗?~4. css3不包括5. javascript - 如何将一个长为365的数组对象按月份切割成12组?6. node.js - npm run dev报错7. node.js - 用npm run dev的文件修改之后npm 没有自动重新运行8. html - angularJS中switch切换开关按钮不能操作9. 求救一下,用新版的phpstudy,数据库过段时间会消失是什么情况?10. node.js - npm安装模块时,在cmd上显示的是一条白线,白线前面是一天反斜线转圈圈,然后就出现npm ERR错误了,求帮助,谢谢

网公网安备