zoukankan
html css js c++ java
一个高效的数据分页的存储过程 可以轻松应付百万数据
CREATE
PROCEDURE
pageTest
--
用于翻页的测试
--
需要把排序字段放在第一列
(
@FirstID
nvarchar
(
20
)
=
null
,
--
当前页面里的第一条记录的排序字段的值
@LastID
nvarchar
(
20
)
=
null
,
--
当前页面里的最后一条记录的排序字段的值
@isNext
bit
=
null
,
--
true 1 :下一页;false 0:上一页
@allCount
int
output,
--
返回总记录数
@pageSize
int
output,
--
返回一页的记录数
@CurPage
int
--
页号(第几页)0:第一页;-1最后一页。
)
AS
if
@CurPage
=
0
begin
--
统计总记录数
select
@allCount
=
count
(ProductId)
from
Product_test
set
@pageSize
=
10
--
返回第一页的数据
select
top
10
ProductId,
ProductName,
Introduction
from
Product_test
order
by
ProductId
end
else
if
@CurPage
=-
1
select
*
from
(
select
top
10
ProductId,
ProductName,
Introduction
from
Product_test
order
by
ProductId
desc
)
as
aa
order
by
ProductId
else
begin
if
@isNext
=
1
--
翻到下一页
select
top
10
ProductId,
ProductName,
Introduction
from
Product_test
where
ProductId
>
@LastID
order
by
ProductId
else
--
翻到上一页
select
*
from
(
select
top
10
ProductId,
ProductName,
Introduction
from
Product_test
where
ProductId
<
@FirstID
order
by
ProductId
desc
)
as
bb
order
by
ProductId
end
查看全文
相关阅读:
mysql命令行操作 添加字段,修改字段
编辑器phpstrom的快捷键修改
echo json数据给ajax后, 需要加上exit,防止往下执行,带上其他数据,到时ajax失败
多选出差同事id,拼接,去掉最后逗号
引入的ajax中异步添加联系人
.NET 4 实践
使用dynamic和MEF实现轻量级的AOP组件 (3)
使用dynamic和MEF实现轻量级的AOP组件 (2)
使用dynamic 和MEF实现轻量级的 AOP 组件 (1)
AOP-SheepAspect
原文地址:https://www.cnblogs.com/zzh/p/314035.html
最新文章
Android中关于Handler的总结
Android中uses-permission权限列表
使用registerReceiver注册BroadcastReceiver
Android中Activity的4种状态
博客第一天
iOS 加密方式
剩余参数
箭头函数
解构赋值
正则替换 replace
热门文章
表单验证正则
正则- 预定义类 验证座机号码的规则
正则案例 匹配 验证用户名
正则
浅拷贝和深拷贝
调用短信接口,先var_dump()看数据类型是object需要json_decode(json_encode( $resp),true)转换成array
jquery收集--php收集所有post数据
弹出框,先弹出遮罩有透明度灰色100%高宽,置顶z-index:999---再弹出框最顶部z-index:9999
form异步无刷新提交,提交后可以显示弹出框,否则弹出框会被刷新不见,使用 preventDefault
常用页面跳转
Copyright © 2011-2022 走看看