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 - 為什么match匹配出來的結果是<_sre.SRE_Match object; span=(0, 54), match=’’>2. mysql優化 - mysql 一張表如果不能確保字段列長度一致,是不是就不需要用到char。3. Python處理Dict生成json4. mysql updtae追加數據sql語句5. python - 請問這兩個地方是為什么呢?6. python - 用os.environ能獲取到的環境變量,在os.environ.getenv卻得不到,這是為什么?7. javascript - 按鈕鏈接到另一個網址 怎么通過百度統計計算按鈕的點擊數量8. python中怎么對列表以區間進行統計?9. 請教一個mysql去重取最新記錄10. 大家都用什么工具管理mysql數據庫?
