56,678
社区成员
发帖
与我相关
我的任务
分享
delimiter $$
create procedure p()
begin
set @f=0, @r=0;
prepare st from 'update t2 a, (select id from t2 limit ?,5000) b set a._id=a.id where a.id=b.id';
w:while true do
execute st using @f;
select @f+found_rows(), found_rows() into @f, @r;
if @r < 5000 then leave w; end if;
end while;
deallocate prepare st;
end$$
delimiter ;
call p;