mysql游标和计数循环次数。如何计算mysql游标中的循环次数

时间:2011-11-05 09:27:21

标签: mysql

如何计算光标中的循环次数

declare counter int;

set counter := 1;
    open cursor1;                           
    LOOP1: loop      

set counter := counter + 1; 

    end loop LOOP1;

但我收到错误:

[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 'set counter := counter + 1; 

    end loop LOOP1;

1 个答案:

答案 0 :(得分:1)

也许您必须删除:中的set才能解决sql语法错误:

set counter = 1;

set counter = counter + 1;