sql server,mysql,oracle 三中数据库分页方式,很有必要的。
sql server:
String sql =
"select top " + pageSize + " * from students where id not in" +
"(select top " + pageSize * (pageNumber-1) + " id from students order by id)" +
"order by id";
mysql:
String sql =
"select * from students order by id limit " + pageSize*(pageNumber-1) + "," +
pageSize;
oracle:
String sql =
"select * from " +
(select *,rownum rid from (select * from students order by postime desc) where
rid<=" + pagesize*pagenumber + ") as t" +
"where t>" + pageSize*(pageNumber-1);