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 - 為什么我的vue里的router-link不起作用2. javascript - 求助Angular 跨控制器調用方法可行嗎?3. CSS更改未得到反映。為什么?4. 用戶在微信小程序支付成功以后,財務在微信支付后臺用交易單號能查到這筆訂單 但財務說錢沒有入對公賬號?5. javascript - node redirect重定向失敗6. javascript - JS使用ele.style.backgoundImage = ’’ =’none’取消背景圖片都無效7. a標簽跨域下載文件能否重命名?8. android - weex 項目createInstanceReferenceError: Vue is not defined9. javascript - 如圖,百度首頁,查看源代碼為什么什么都沒有?10. pdo 寫入到數據庫的內容為中文的時候寫入亂碼
