mysql loop循环ecshop商品信息

2012-11-27 15:20 来源:www.chinab4c.com 作者:ecshop专家

    mysql loop循环ecshop商品信息,主要就是通过mysql的循环,结合mysql的procudure存储过程和cursor游标来处理ecshop商品ID,高效的调用ecshop信息;

create procedure c2()
BEGIN
declare a varchar(255) default '';
declare b varchar(255) default '';
declare gid int default 0;
declare c cursor for select goods_id from ecs_goods;
declare continue handler for not found set gid = 0;
open c;
llp:LOOP
fetch c into gid ;
if gid = 0 then
leave llp;
end if;
set a = concat(gid,":");
set b = concat(b,a);
end loop llp;

close c;
select b;
end;

来源:http://www.chinab4c.com