2009年3月20日星期五

数据库翻页

1.Oracle
select * from ( select rownum idx,* from TableName ) where idx >= ? and idx <= ?

2.SQL Server
select top @pagesize * from tablename where id notin (
select top @pagesize*(@page-1) id from tablenameorder by id
) order by id

3.MySQL
select * from tablename limit position, counter

4.DB2
select * from (
select *,rownumber() over(字段 ASC) as idx from TableName )
where idx >= ? and idx <= ?

没有评论: