在mysql存储过程中使用limit 常量 没有问题.但是 limit 变量 编译不通过.如何解决?下面是我的代码!!很急
CREATEPROCEDUREpro_delAlbumById(INidint)BEGINdeclarephotoIdsvarchar(255);declarephoto...
CREATE PROCEDURE pro_delAlbumById
(
IN id int
)
BEGIN
declare photoIds varchar(255);
declare photoCount int;
declare var int;
set var=0;
set photoCount = (select count(1) from tx_photo where a_id=id );
while var<photoCount do
if var=0 then
set photoIds = (select p_id from tx_photo where a_id=id limit var,1);
else
set photoIds = photoIds+','+(select p_id from tx_photo where a_id=id limit var,1);
end if;
set var=var+1;
end while;
select photoCount;
END; 展开
(
IN id int
)
BEGIN
declare photoIds varchar(255);
declare photoCount int;
declare var int;
set var=0;
set photoCount = (select count(1) from tx_photo where a_id=id );
while var<photoCount do
if var=0 then
set photoIds = (select p_id from tx_photo where a_id=id limit var,1);
else
set photoIds = photoIds+','+(select p_id from tx_photo where a_id=id limit var,1);
end if;
set var=var+1;
end while;
select photoCount;
END; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询