分页查询

 

oracle 分页:

查询第21条至第40条(共20条)数据

select t2.*
  from (select t1.*, rownum r from eshop_order t1 where rownum <= 40) t2
 where t2.r >= 21;



 

SELECT *
  FROM (SELECT t.*, ROWNUM RN
          FROM (SELECT * FROM eshop_order) t
         WHERE ROWNUM <= 40)
 WHERE RN >= 21;



 

MySQL分页:

从第10条记录开始检索20条记录

select * from tableName limit 10,20; 



 

 

Hibernate 自带分页:

String hql = "from EshopOrder"; 
Query query = session.createQuery(hql); 
query.setCacheable(true); 
List result = query.setFirstResult(start).setMaxResults(pageSize).list(); 
start为起始行,pageSize为记录数即每页显示的条数,int start = (page - 1) * pageSize;



 

你可能感兴趣的:(分页查询)