日期:2014-05-16 浏览次数:20462 次
select * from user limit 10,10;
//方法一 先取前20条记录然后再去除前10条记录,不过效率不高 select top 20 from user where id not in (select top 10 from user); //方法二 先建立自增id的临时表,然后判断10<id<20就可以了 select identity(int,1,1) as id,* into #temp from user; select * from #temp where id between 10 and 20; //方法三 应该比较高效了,先取前20条记录,然后将结果集倒序,取前十条就行 select top 10 from (select top 20 from user order by id) t order by t.id desc;
select * from (select rownum r ,u.* from user u where r<=20) where r>=10;