求WHILE循环写法!!急!!!加班中!!1

renshaohai8810611 2006-08-07 09:22:41

DECLARE I int;
DECLARE J int;
set I=100000;
set J=1;


while I<=120000 do
begin

while J<=10 do
begin

insert into t_favorites values (I,I,I,J,'1','0','100','1','0',now()+0,now()+0,now()+0,now()+0,'1');

if(J=10) then

set J=1;

else
set J=J+1;

end if;
end;
end while;

set I=I + 1;

end;
end while;
end;

报错..请教怎么修改??
...全文
250 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
mschen 2006-08-08
  • 打赏
  • 举报
回复
不好意思.

insert into t_favorites values (I,I,I,J,'1','0','100','1','0',now()+0,now()+0,now()+0,now()+0,'1');


上边是你原来的插入语句,换回来就好了.
renshaohai8810611 2006-08-08
  • 打赏
  • 举报
回复
ERROR 1062 (23000): Duplicate entry '1' for key 1

我在CALL后出现了如下错误...在CALL前已经执行了DELETE语句....
mschen 2006-08-07
  • 打赏
  • 举报
回复
-- 这样测试OK.

Delimiter $$

Create Procedure P_test()
Begin
DECLARE I int;
DECLARE J int;
set I=100000;
set J=1;
while (I<=120000) do
begin
while (J<=10) do
begin
insert into t_favorites values (I,J) ;
if(J=10) then
set J=1;
else
set J=J+1;
end if;
end;
end while;
set I=I + 1;
end;
end while;
end$$


Call p_test();
renshaohai8810611 2006-08-07
  • 打赏
  • 举报
回复
MYSQL扳快怎么没人应啊???

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧