mysql的循環(huán)語句問題
問題描述
要多次的執(zhí)行一個select操作,就想著用循環(huán)來實現(xiàn),在網(wǎng)上查了一些內(nèi)容,顯示的做法都是差不多的,就是總是提示語言錯誤,很是郁悶,各位大俠幫忙看看,要怎么改才可以。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;
錯誤信息:[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.創(chuàng)建存儲過程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. docker綁定了nginx端口 外部訪問不到2. dockerfile - 為什么docker容器啟動不了?3. git - webstorm窗口中左側(cè)列表的文件名顏色怎么修改4. android權(quán)限被第三方安全軟件禁止,如何獲取該權(quán)限狀態(tài)5. javascript - 深夜被問題困擾求解惑,rn的API之PermissionsAndroidd的問題6. javascript - 最近用echarts做統(tǒng)計圖時遇到兩個問題!!7. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?8. mysql - 我的myeclipse一直連顯示數(shù)據(jù)庫連接失敗,不知道為什么9. tp 6.0 數(shù)據(jù)查詢,求教!10. mysqld無法關(guān)閉

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