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. javascript - 请问这段 el && fn.call(el, e, el)代码这么写什么意思?2. pdo_mysql 值自增写法3. css - 这些字体是怎么弄的?4. 如何解决tp6在zend中无代码提示5. python - requests post问题6. javascript - JS 里面的 delete object.key 到底删除了什么?7. javascript - chart.js如何修改某个指定bar的颜色8. html - 关于css选择器的问题9. python - 怎样在linux下开发flask web应用时查看代码出错(traceback)的地方。10. PHP中的$this代表当前的类还是方法?

网公网安备