取前几条记录

时间:2022-07-17 15:08:55
介�B取一表前N�P��的各种�稻�斓��法...
1. ORACLE
SELECT * FROM TABLE1 WHERE ROWNUM<=N
2. INFORMIX
SELECT FIRST N * FROM TABLE1
3. DB2
SELECT * ROW_NUMBER() OVER(ORDER BY COL1 DESC) AS ROWNUM WHERE ROWNUM<=N
DB2
SELECT COLUMN FROM TABLE FETCH FIRST N ROWS ONLY
4. SQL SERVER
SELECT TOP N * FROM TABLE1
5. SYBASE
SELECT TOP N * FROM TABLE1
6. mysql:
select * from table_name limit N
    1):select   *   from   fromname   where   rownum<=10   2):如果需要排序,在8i中是  
  select   *   from   (select   *   from   table   order   by   ……)   where   rownum<10
3):select 字段1,字段2 from (select * from infotb order by infoid desc) where rownum<=5
子查询内没有的字段,外查询就不能查这个字段.