[笔记]Oracle、MySQL和DB2数据库分页查询的实现

来源:互联网 发布:网博 软件测试 编辑:程序博客网 时间:2024/04/26 00:14
1.Oracle分页查询


SELECT * FROM (
       SELECT tt.*,ROWNUM AS rowno 
               FROM (
                    SELECT t.info_id,t.title,t.source,t.content,t.verify_time 
                            FROM CMS_INFORMATION t where t.info_id is not null
                                 ) tt   WHERE ROWNUM <= #endIndex#) 
                tab WHERE tab.rowno > #startIndex# 






2.DB2分页查询


SELECT * FROM (
         SELECT rownumber() over() as rc,a.* from 
            (select INFO_ID,TITLE,AUTHOR,SOURCE,SUMMARY,CONTENT,LAST_MODIFYTIME from CMS_INFORMATION order by INFO_ID desc)
as a) where rc between 

              #startIndex# and #endIndex#


3.MySQL分页查询(以每页显示10条为准)

select * from table limit (#currentPage#-1)*10,10;


阅读全文
1 0