mysql的循環(huán)語句問題
問題描述
要多次的執(zhí)行一個(gè)select操作,就想著用循環(huán)來實(shí)現(xiàn),在網(wǎng)上查了一些內(nèi)容,顯示的做法都是差不多的,就是總是提示語言錯(cuò)誤,很是郁悶,各位大俠幫忙看看,要怎么改才可以。mysql數(shù)據(jù)庫、navicat客戶端。mysql循環(huán)的操作語句:
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;
錯(cuò)誤信息:[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:你這是再寫存儲(chǔ)過程嗎?1.創(chuàng)建存儲(chǔ)過程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.調(diào)用call pro10()
相關(guān)文章:
1. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問題3. phpstudy8.1支持win11系統(tǒng)嗎?4. javascript - 移動(dòng)端上不能實(shí)現(xiàn)拖拽布局嗎?5. 實(shí)現(xiàn)bing搜索工具urlAPI提交6. 如何解決Centos下Docker服務(wù)啟動(dòng)無響應(yīng),且輸入docker命令無響應(yīng)?7. vue.js - Vue 如何像Angular.js watch 一樣監(jiān)聽數(shù)據(jù)變化8. javascript - nodejs關(guān)于進(jìn)程間發(fā)送句柄的一點(diǎn)疑問9. javascript - ios返回不執(zhí)行js怎么解決?10. javascript - react native在run-android時(shí)出現(xiàn)這個(gè)錯(cuò)誤該怎么解決?大神賜教

網(wǎng)公網(wǎng)安備