Oracle不支持select top 语句,所以Oracle中经常使用order by 跟 rownumber
的组合来实现select top N 的查询。
sqlServer:
select top 5 from (select top 10 from tab_users order by id) t
order by id desc;
Oracle查询从第5到第10条记录:
select * from (select rownum r,a.* from tab_users a where rownum<=10) where r>=5;
MySQL的查询使用limit
select * from tab_users limit 0,10 ;
的组合来实现select top N 的查询。
sqlServer:
select top 5 from (select top 10 from tab_users order by id) t
order by id desc;
Oracle查询从第5到第10条记录:
select * from (select rownum r,a.* from tab_users a where rownum<=10) where r>=5;
MySQL的查询使用limit
select * from tab_users limit 0,10 ;