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. 关于python爬虫的问题2. mysql新建字段时 timestamp NOT NULL DEFAULT ’0000-00-00 00:00:00’ 报错3. python - nginx为什么不能反代图片?4. Browser-sync安装失败问题5. python - pip install出现下面图中的报错 什么原因?6. mysql5.7 安装后无法设置密码7. javascript - js输入框限定字数问题8. windows-7 - Win7中Vmware Workstatoin与Xampp中Apache服务器端口冲突?9. html5 - api.douban.com/v2/movie/in_theaters?start=0&count=3 不在以下合法域名列表中10. css - autoprefixer没有添加web-kit前缀

网公网安备