


下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、sql server分页查询原理设有myschool数据库,表结构如下:其中表student的主键是studentid执行select * from student显示表的内容:如果只显示前5条数据,则sql语句是:select top 5 * from student如果只显示第610条数据,则sql语句是:select top 5 * from student where studentid not in(select top 5 studentid from student)如果只显示第1115条数据,则sql语句是:select top 5 * from student where s
2、tudentid not in(select top 10 studentid from student)其实,如果只显示第15条数据也可以这样写:select top 5 * from student where studentid not in(select top 0 studentid from student)这个例子可以看做是把21条数据分页显示,每页显示5项,设总记录条数是sumrow,每页显示的数据行数是pagerow,则要分的页数是pages是:pages=(sumrow+1)/pagerow+1 上例子中sumrow=21,pagerow=5,则要分的页数pages=(21
3、+1)/5+1=5页。第一页的查询语句是:select top 5 * from student where studentid not in(select top 0 studentid from student)第二页的查询语句是(相当于,乘号只是为了便于理解,写语句不能这样,下同):select top 5 * from student where studentid not in(select top 5*1 studentid from student)第三页的查询语句是:select top 5 * from student where studentid not in(select top 5*2 studentid from student)第四页的查询语句是:select top 5 * from student where studentid not in(select top 5*3 studentid from student)第五页的查询语句是:select top 5 * from student where studentid not in(select top 5*4 studentid from student)由此,总结出分页查询的公式如下:select top pagerow (每页显示的数据行数) f
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 解除公司转让合同协议
- 茶叶买卖合同协议模板
- 纺织品设计的市场营销策略研究试题及答案
- 纺织技术在设计创新中的作用试题及答案
- 国际商业美术设计师考试中的色彩运用与试题及答案
- 能力检测试题及答案
- 英语2试题及答案解析版
- 2025年罕见病药物研发激励政策对产业政策环境的推动作用分析
- 广告设计师证书考试图形设计常见问题试题及答案
- 检验员考试中常见的难点与突破策略试题及答案
- 糖尿病合并痛风
- 中西文化鉴赏知到智慧树章节测试课后答案2024年秋郑州大学
- 管理心理学-第二次形成性考核-国开(SC)-参考资料
- 口腔健康教育宣讲
- 《商业银行经营管理》课件-商业银行中间业务及表外业务管理
- 牙科市场细分领域分析-洞察分析
- 初一英语期中考试质量分析
- 第16课《经济危机与资本主义国家的应对》中职高一下学期高教版(2023)世界历史全一册
- 猎聘测评题库
- 货运车队的管理制度模版(2篇)
- 2024年贵州省贵阳市中考生物试卷(附答案)
评论
0/150
提交评论