这是我搞了很久写出来的,不是存储过程。是sql语句.帮我简化下
declare @page int --当前页
declare @count int --每页显示多少行数据
set @page=1
set @count=5
//查询回复表的回复内容主题为3的字段,以及回复人的个人资料
select a.replyid, a.topicid, a.forumid, a.uid, a.title, a.replytext,
a.replaytime AS messagetime, b.lastreptime, c.email, c.sex, c.photo,
c.ugrade, c.mysetting,
c.newtime, c.lastlongetime, c.Integral
from (select *,
row_number() over( order by replyid) as id from replies where topicid=3) as a
INNER JOIN
dbo.topics AS b ON a.topicid = b.topicid INNER JOIN
dbo.users AS c ON a.uid = c.uid
where a.id >@count*(@page-1) and a.id<=@count*(@page)
//显示共有多少条回复,和可分为多少页
select count(*)as psum,(count(*))/@count as page from replies where topicid=3