分页语句:
Oracle:
--这种分页查询方式不仅仅是针对单表的简单查询,对于最内层查询是复杂的
--多表联合查询或最内层查询包含排序的情况一样有效
SELECT * FROM (
SELECT ROWNUM RN , T.* FROM
(SELECT * FROM FTNEMR.PATIENT_VISIT) T WHERE ROWNUM <= 40 )
WHERE RN >= 21
ORDER BY PATIENT_ID;
--这种方式比上面的方式要性能要低很多
SELECT * FROM (
SELECT ROWNUM RN, T.* FROM
(SELECT * FROM FTNEMR.PATIENT_VISIT) T )
WHERE RN BETWEEN 21 AND 40
ORDER BY PATIENT_ID
SQL Server:
--查询出第21条至第30条数据 --
SELECT TOP 10 * FROM dbo.HIS_BA1
WHERE FID NOT IN(SELECT TOP 20 FID FROM dbo.HIS_BA1 ORDER BY FID)
Mysql:
SELECT * FROM table LIMIT 5,10; // 检索记录行 6-15
原文地址:http://blog.csdn.net/sunlovefly2012/article/details/25237681