|M| 求SQL查询语句,查询出表中第11条到20条的记录

zyciis229 2007-04-30 11:17:16
如select * from tab1
现在要求是
select 11 to 20 from tab 这样的

谢谢
...全文
652 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
anan221 2007-05-01
  • 打赏
  • 举报
回复
Select top 10 From tab1 where id not in
(Select top 10 from tab1 order by id)
hertcloud 2007-05-01
  • 打赏
  • 举报
回复
select top 10 [LogID], [UserID] from TB_ActiveLog where LogID <
(select min(LogID) from (select top 10 LogID from TB_ActiveLog order by LogID DESC ) AS TBMinID) order by LogID DESC

这个是数据 倒排的时候 从第一条开始

select top 10 [LogID], [UserID] from TB_ActiveLog where LogID >
(select max(LogID) from (select top 10 LogID from TB_ActiveLog order by LogID ASC ) AS TBMinID) order by LogID ASC
shadow841112 2007-04-30
  • 打赏
  • 举报
回复
select top 5 * from (select top 15 * from table order by id asc) table_别名 order by id desc
hertcloud 2007-04-30
  • 打赏
  • 举报
回复
not in在 几十万 数据 的情况 还可以...

top max 可以 应付 千万级的分页.



但是楼主要注意点 这两种分页 模式下 你的 排序 主键 都必须的 不重复值的.

如果重复 那么sql 2005以前 需要 临时表 解决
sql 2005 有 row_number 很好用
hertcloud 2007-04-30
  • 打赏
  • 举报
回复
这里有 这两种 形式的 分页通用过程
http://blog.csdn.net/hertcloud/category/281167.aspx

zyciis229 2007-04-30
  • 打赏
  • 举报
回复
select top 5 * from (select top 15 * from table order by id asc) table_别名 order by id desc

这里面有对id 进行排序
要是我本来要查询的数据id是很乱的而不是顺的 就不行了

selecct top 5 * from table where id not in (select top 10 id from table order by id asc) order by id asc

这条看起来还有点可行但是要是
selecct top 5 * from table where id not in (select top 10000 id from table order by id asc) order by id asc
这样要对10000条数据进行比较会不会太慢了

hertcloud 2007-04-30
  • 打赏
  • 举报
回复
对于 GUID只能 使用上面的形式
对于int类型 可以使用 效率更好的.

select top 10 [LogID], [UserID] from TB_ActiveLog where LogID <
(select min(LogID) from (select top 10 LogID from TB_ActiveLog order by LogID DESC ) AS TBMinID) order by LogID DESC
hertcloud 2007-04-30
  • 打赏
  • 举报
回复
select top 10 [LogID], [UserID], [TrueName] from TB_ActiveLog where LogID not in(select top 10 LogID from TB_ActiveLog order by LogID DESC ) order by LogID DESC
amandag 2007-04-30
  • 打赏
  • 举报
回复
求m~n条
Select top (n-m+1) * From tab1 where id not in
(Select top m id from tab1 order by id)
order by id
================================================

这个是个比较经典的案例了
ly_0205 2007-04-30
  • 打赏
  • 举报
回复
sql server 这样: 其它数据库可能有支持你写的那种方式

select top 20 identity(int,1,1) lineSN,* into # from tab1
select * from # where lineSN > 10
drop table #
RexZheng 2007-04-30
  • 打赏
  • 举报
回复
选择从10到15的记录

select top 5 * from (select top 15 * from table order by id asc) table_别名 order by id desc


or



selecct top 5 * from table where id not in (select top 10 id from table order by id asc) order by id asc
最后一只恐龙 2007-04-30
  • 打赏
  • 举报
回复
求m~n条
Select top (n-m+1) * From tab1 where id not in
(Select top m id from tab1 order by id)
order by id

上个帖子top 10后面把*和id都忘了
最后一只恐龙 2007-04-30
  • 打赏
  • 举报
回复
按id排序
Select top 10 From tab1 where id not in
(Select top 10 from tab1 order by id)
order by id
分布式微服务企业级系统是一个基于Spring、SpringMVC、MyBatis和Dubbo等技术的分布式敏捷开发系统架构。该系统采用微服务架构和模块化设计,提供整套公共微服务模块,包括集中权限管理(支持单点登录)、内容管理、支付中心、用户管理(支持第三方登录)、微信平台、存储系统、配置中心、日志分析、任务和通知等功能。系统支持服务治理、监控和追踪,确保高可用性和可扩展性,适用于中小型企业的J2EE企业级开发解决方案。 该系统使用Java作为主要编程语言,结合Spring框架实现依赖注入和事务管理,SpringMVC处理Web请,MyBatis进行数据持久化操作,Dubbo实现分布式服务调用。架构模式包括微服务架构、分布式系统架构和模块化架构,设计模式应用了单例模式、工厂模式和观察者模式,以提高代码复用性和系统稳定性。 应用场景广泛,可用于企业信息化管理、电子商务平台、社交应用开发等领域,帮助开发者快速构建高效、安全的分布式系统。本资源包含完整的源码和详细论文,适合计算机科学或软件工程专业的毕业设计参考,提供实践案例和技术文档,助力学生和开发者深入理解微服务架构和分布式系统实现。 【版权说明】源码来源于网络,遵循原项目开源协议。付费内容为本人原创论文,包含技术分析和实现思路。仅供学习交流使用。

62,253

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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