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. java 排序的问题2. 网络传输协议 - 以下三种下载方式有什么不同?如何用python模拟下载器下载?3. 我在centos容器里安装docker,也就是在容器里安装容器,报错了?4. 如何修改phpstudy的phpmyadmin放到其他地方5. angular.js - Angular路由和express路由的组合使用问题6. 我的html页面一提交,网页便显示出了我的php代码,求问是什么原因?7. node.js - gulp文件监听的问题8. 数据库 - 使用读写分离后, MySQL主从复制延迟会导致读不到数据吗?9. php - mysql中,作为主键的字段,用int类型,是不是比用char类型的效率更高?10. tp6表单令牌
