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 - 手機點擊input時,button會被頂上去?求解決!!!2. 百度地圖api - Android 百度地圖 集成了定位,導航 相互的jar包有沖突?3. python - django 按日歸檔統計訂單求解4. 網頁爬蟲 - python爬蟲用BeautifulSoup爬取<s>元素并寫入字典,但某些div下沒有這一元素,導致自動寫入下一條,如何解決?5. javascript - vue-mint UI - icon在哪里有文檔?6. HTML5禁止img預覽該怎么解決?7. javascript - vscode alt+shift+f 格式化js代碼,通不過eslint的代碼風格檢查怎么辦。。。8. html5 - 表單無法屏蔽自動填充 autocomplete=off9. html - 請教一個前端css問題。10. 請教一個python字符串處理的問題?
