在做web项目时经常遇到新闻要上一篇,下一篇,自己先记下以纺万一忘记了

上一篇
create proc Prev
(
  
@ID
)
as
declare @Record int
set @Record = (select count(ID) from News where ID<@ID)
if @Record>0
  
begin
     
select top 1 ID from News where ID<@ID order by ID desc
  
end
else
  
begin
     
select max(ID) from News
  
end
下一篇
create proc Next
(
  
@ID
)
as
declare @Record int
set @Record = (select count(ID) from News where ID>@ID)
if @Record>0
  
begin
     
select top 1 ID from News where ID>@ID 
  
end
else
  
begin
     
select min(ID) from News
  
end

 

 

 

 

 

 

 

  

相关文章:

  • 2021-07-04
  • 2021-11-03
  • 2021-10-08
  • 2022-03-10
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2021-04-11
相关资源
相似解决方案