数据库分页查询

  1、SQLite数据库分页查询:

select * from users order by id limit 10 offset 0;//offset代表从第几条记录“之后“开始查询,limit表明查询多少条结果

运用: string sqlPage= string.Format("select * from users order by id limit {0} offset {1}",dp.PageSize, dp.PageSize * dp.PageIndex);

SQLite中没有Top关键字,仿Sql中的Top运用:排序后取前1000条数据

select * from users order by id desc limit 0,1000

2、ACCESS数据库分页查询:

string sqlPage = string.Format("select * from (select top {0} * from (select top {1} * from users ORDER BY id DESC) ORDER BY id ASC) ORDER BY id DESC",dp.PageSize, dp.PageSize*dp.PageIndex);

posted on 2019-09-17 10:35  BennyHua  阅读(188)  评论(0编辑  收藏  举报

导航