总结Oracle,sqlserver,mysql中查询10-20条记录的写法

时间:2021-12-14 15:01:26

一: oracle数据库写法:

1:select * from (select rownum rn ,* from 表名 wher rownum<20) a

where a.rn>10

2:select * from 表名 where rownum<20

  minus

  select * from 表名 where rownum<10

二: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条

三:mysql的写法:

select * from tablename where LIMIT 9,10