在一个项目中,分页功能可以说是必不可少,在常用的数据库中,其中mysql的分页比较简单,这里列出sqlserver 和 oracle的分页sql。

SQLServer:

SELECT   *   FROM       
            (       
            SELECT   TOP(PageSize)   *   FROM       
            (       
                      SELECT   TOP   (PageSize   *   PageIndex)   *       
                      FROM   Articles       
                      ORDER   BY   id   DESC       
            )       
            ORDER   BY   id   ASC       
  )       
  ORDER   BY   id   DESC

Oracle:

select   *   from   (       
select   rownum   num,t1.*       
  from   table   t1   where   fast=0       
)   where   num>=intPosition   and   num<=intEndPosition
你可能感兴趣的内容
0条评论

selfly

交流QQ群:32261424
Owner