查询前几条记录在不同数据库中的用法
1. ORACLE
SELECT * FROM TABLE1 WHERE ROWNUM<=N
2. DB2
SELECT * ROW_NUMBER() OVER(ORDER BY COL1 DESC) AS ROWNUM WHERE ROWNUM<=N
或者
SELECT COLUMN FROM TABLE FETCH FIRST N ROWS ONLY
3. SQL SERVER
SELECT TOP N * FROM TABLE1
4. SYBASE
SET ROWCOUNT N
GO
SELECT * FROM TABLE1
5. MYSQL
SELECT * FROM TABLE1 LIMIT N
要实现先排序,再取前几名用下面这条语句
select * from (select * from table order by 字段名 desc) where rownum<n
作者 cuiran