delete from table where id = 传入的参数.============== 我以前写的一个查询的.你参考一下吧. DELIMITER $$DROP PROCEDURE IF EXISTS `test`.`sp_gehang`$$CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_gehang`() BEGIN DECLARE cnt int; declare cnt2 int; -- declare cnt3 int; declare i int; select count(*) from song into cnt; select ceil(cnt/100) into cnt2; set i=0; loop1:loop set i = i + 1; -- select 2*i into cnt3; if i > cnt2 then leave loop1; end if; set @smt = 'select * from song limit ?,1;'; prepare s1 from @smt; -- set @cnt3 = 2*i; set @cnt3 = 100*i; execute s1 using @cnt3; deallocate prepare s1 ; end loop loop1; END$$DELIMITER ;
declare @str varchar(8000) set @str='' select @str=@str+'drop procedure '+name+char(10) from sysobjects where xtype='P' exec(@str)
我以前写的一个查询的.你参考一下吧.
DELIMITER $$DROP PROCEDURE IF EXISTS `test`.`sp_gehang`$$CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_gehang`()
BEGIN
DECLARE cnt int;
declare cnt2 int;
-- declare cnt3 int;
declare i int;
select count(*) from song into cnt;
select ceil(cnt/100) into cnt2;
set i=0;
loop1:loop
set i = i + 1;
-- select 2*i into cnt3;
if i > cnt2 then
leave loop1;
end if;
set @smt = 'select * from song limit ?,1;';
prepare s1 from @smt;
-- set @cnt3 = 2*i;
set @cnt3 = 100*i;
execute s1 using @cnt3;
deallocate prepare s1 ;
end loop loop1;
END$$DELIMITER ;
set @str=''
select @str=@str+'drop procedure '+name+char(10) from sysobjects where xtype='P'
exec(@str)