日期:2014-05-16 浏览次数:20632 次
都以student表为例
1、mysql
select * from student limit startposition,pageSize
?注意初始记录行的偏移量是 0而非1
2、sql server2000,2005
SELECT TOP 页大小 * FROM student WHERE id NOT IN ( SELECT TOP 页大小*(页数-1) id FROM student ORDER BY id ) ORDER BY id?
SELECT TOP 页大小 * FROM student WHERE id > ( SELECT ISNULL(MAX(id),0) FROM ( SELECT TOP 页大小*(页数-1) id FROM student ORDER BY id ) A ) ORDER BY id
?3、oracle
SELECT * FROM (SELECT ROWNUM r,t1.* From student t1 where ROWNUM < startPosition+pageSize) t2 where t2.r >= startPosition