oracle mssql mysql db2 取前几条数据

来源:互联网 发布:高速公路的数据 编辑:程序博客网 时间:2024/04/30 05:11

oracle mssql mysql db2 取前几条数据


如在ms   sqlserver   用此语句:   
select   top   2   *   from   news   就会只显示前2条记录,   
   


MYSQL
select   *   from   news   where   ....   limit   2;   
    
使用limit就可以了.
Oracle的语句: 
select * from (select rownum rows ,* from news) temp 
where temp .rows  > 50 and temp .rows  <= 100; (最好用PLSQL游标来解决)


DB2中: 
select * from  news   fetch first 5 row only --查前5条记录


DB2中查找出第n行到第m行的数据记录
Select * 
from (select 列名1 , 列名2  , row_number() over() as a   from 表名) as 表别名
where a>=10 and a<=20;

0 0
原创粉丝点击