posts - 167,  comments - 30,  trackbacks - 0
Oracle数据库写法:
--查询第5-10条记录
方式一:
select * from (select rownum myrow,t.* from efb_random_pwd t) where myrow between 5 and 10;

以下两种方式数据量大的时候效率好些。
方式二:

select * from (select rownum r,a.* from efb_random_pwd a where rownum<=20) where r>=10;   
方式三:
select * from efb_random_pwd where rowid in(
    select rid from (select rownum num,rowid rid from efb_random_pwd a where rownum <=10) where num > = 5);

MySql数据库写法:

select   *   from   tablename   where   LIMIT   9,10

 从10条开始取,取10条,则就是10--20


SqlServer数据库写法:

1:select top 20 * from tablename where id not exists (select top 10 * from tablename)//前20条记录再过滤掉前10条

2:select top10 * from (select top 20 * from order by column) order by column desc//子查询中取20条倒序,然后从子查询中取前10条


 


posted on 2011-01-20 13:33 David1228 阅读(179) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

<2011年1月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

常用链接

留言簿(4)

随笔分类

随笔档案

文章档案

新闻分类

新闻档案

相册

收藏夹

Java

Linux知识相关

Spring相关

云计算/Linux/虚拟化技术/

友情博客

多线程并发编程

开源技术

持久层技术相关

搜索

  •  

积分与排名

  • 积分 - 353975
  • 排名 - 155

最新评论

阅读排行榜

评论排行榜