我需要使用sql命令在ms访问中对数据进行分页吗?

时间:2015-12-13 19:08:02

标签: php ms-access pagination odbc

由于ms访问中没有本机偏移功能,我使用以下技术对本教程中的数据进行分页:http://www.jertix.org/en/blog/programming/implementation-of-sql-pagination-with-ms-access.html

 Select TOP Row_Per_Page * From [
    Select TOP (TotRows - ((Page_Number - 1) * Row_Per_Page) 
    From SampleTable Order By ColumnName DESC
 ] Order By ColumnName ASC

 --Page 1
 SELECT TOP 4 * FROM [SELECT TOP 17 * FROM SampleTable ORDER BY ID DESC; ]. 
 AS t1 ORDER BY ID;

 --Page 2 
 SELECT TOP 4 * FROM [SELECT TOP 13 * FROM SampleTable ORDER BY ID DESC; ]. 
 AS t1 ORDER BY ID;

 --Page 3 
SELECT TOP 4 * FROM [SELECT TOP  9 * FROM SampleTable ORDER BY ID DESC; ]. 
AS t1 ORDER BY ID;

 --Page 4  
 SELECT TOP 4 * FROM [SELECT TOP  5 * FROM SampleTable ORDER BY ID DESC; ]. 
 AS t1 ORDER BY ID;

 --Page 5  
 SELECT TOP 4 * FROM [SELECT TOP  1 * FROM SampleTable ORDER BY ID DESC; ]. 
 AS t1 ORDER BY ID;

使用这种技术,对于第一页,数据库必须选择子查询中的所有记录。这种技术是否与mysql偏移和限制一样有效。如果不是我不认为,在SQL端需要分页。我可以使用一些客户端分页可能与一些JavaScript。有没有更好的方法在ms访问中进行分页,或者我最好不分页,因为没有真正优于性能的优势?

0 个答案:

没有答案