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 阅读(187)
评论(0) 编辑 收藏