http://blog.csdn.net/hbcui1984/archive/2006/10/18/1340179.aspx
http://blog.csdn.net/xuezj508/archive/2007/04/15/1565372.aspx
http://blog.csdn.net/LEOlws/archive/2006/12/27/1465128.aspx
[label:] REPEAT
statements
UNTIL expression
END REPEAT [label] ;
[label:] LOOP
statements
END LOOP [label];
[label:] WHILE expression DO
statements
END WHILE [label] ;
-------------------
DELETE FROM tbl_name WHERE 1>0;
注意这比没有WHERE子句的DELETE FROM tbl_name慢的多了,因为它一次删除一行
可以加上limit
repeat
fetch next from test_cur into idd,datetime,type,count;
set tt=tt+1;
insert into test.event (datetime,type,count) values('2','2',2);
UNTIL (tt>10) //直到大于十为止
end repeat;
--------------------
while(tt<10) do
fetch next from test_cur into idd,datetime,type,count;
set tt=tt+1;
insert into test.event (datetime,type,count) values('2','2',2);
end while;
---------------
begin
declare idd int(10);
declare tt int(10);
declare datetime varchar(200);
declare type varchar(200);
declare count int(10);
declare test_cur cursor for select id,datetime,type,count from test.event;
open test_cur;
set tt=1;
repeat
fetch next from test_cur into idd,datetime,type,count;
set tt=tt+1;
insert into test.event (datetime,type,count) values('2','2',2);
UNTIL (tt>10)
end repeat;
close test_cur;
end