Sqlserver的一个存储过程转化为mysql的的?

sccxszy 2008-10-29 10:51:35

create procedure Pager
(
@cate VarChar(10),
@startIndex int,
@endIndex int,
@docount bit)
as
set nocount on
if(@docount=1)
select count(*) from wp_posts
else
begin
declare @indextable table(id int identity(1,1),nid int)
set rowcount @endIndex
insert into @indextable(nid) select id from wp_posts order by id desc
select * from wp_posts O,@indextable t where O.id=t.nid
and t.id between @startIndex and @endIndex order by t.id
end
set nocount off


aspnetpager生成的sqlserver2000的分页存储过程,想转换为mysql可用,麻烦大侠修改下,或者推荐一个好用的mysql分页存储过程。
...全文
171 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sccxszy 2008-10-30
  • 打赏
  • 举报
回复
那个版块太冷清了,先发哪里的,才转过来,不行又转过去。
hyde100 2008-10-30
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wufeng4552 的回复:]
最好到MYSQL問問看,或許更快~~
[/Quote]
水族杰纶 2008-10-30
  • 打赏
  • 举报
回复
最好到MYSQL問問看,或許更快~~
dawugui 2008-10-30
  • 打赏
  • 举报
回复
来错地方了,麻烦钻钻转帖.
懒得去死 2008-10-30
  • 打赏
  • 举报
回复

delimiter ||

create procedure Pager (
f_cate VarChar(10),
f_startIndex int,
f_endIndex int,
f_docount bit,
OUT o_rowcount int
)
begin
if (f_docount=1) then
select count(*) from wp_posts;
else
begin
create temporary table indextable(id int unsigned not null auto_increment primary key,nid int);
set o_rowcount = f_endIndex;
insert into indextable(nid) select id from wp_posts order by id desc;
set @stmt = concat('select * from wp_posts O,indextable t where O.id=t.nid and t.id between',
f_startIndex,' and ',f_endIndex,' order by t.id');
prepare s1 from @stmt;
execute s1;
drop prepare s1;
drop table indextable;
set @stmt = NULL;
end;
end if;
end||
delimiter ;

56,675

社区成员

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

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