查询前几条记录SQL在不同数据库中的用法;
lgl669
2009-06-16
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 或者 SELECT COLUMN FROM TABLE FETCH FIRST N ROWS ONLY 4. SQL SERVER SELECT TOP N * FROM TABLE1 5. SYBASE SET ROWCOUNT N GO SELECT * FROM TABLE1 6. MYSQL SELECT * FROM TABLE1 LIMIT N 7. FOXPRO SELECT * TOP N FROM TABLE ORDER BY COLUMN 不过个人认为oracle的rownum查询不太好,喜欢使用rank函数进行排序和部分记录的选择(好比前几条,中间几条)。 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/yifeiyuann/archive/2006/04/24/675398.aspx |