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. vim - win10無法打開markdown編輯器3. mysql - 千萬數據 分頁,當偏移量 原來越大時,怎么優化速度4. 如何解決tp6在zend中無代碼提示5. javascript - 有沒有類似高鐵管家的時間選擇插件6. 這是什么情況???7. python - flask學習,user_syy添加報role is invalid keyword for User.8. css - BEM 中塊(Block)有木有什么標準 何時決定一個部分提取為塊而不是其父級的元素呢(Element)?~9. css3 - less或者scss 顏色計算的知識應該怎么學?或者在哪里學?10. javascript - 微信網頁開發從菜單進入頁面后,按返回鍵沒有關閉瀏覽器而是刷新當前頁面,求解決?
