mssql 支持的分页+sqlite + mysql 的分页语句

前端之家收集整理的这篇文章主要介绍了mssql 支持的分页+sqlite + mysql 的分页语句前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

msql

=================================

select count(*)/10 from hy_jbxx

select top 10 *
from hy_jbxx
where (hybh not in
(select top 30 hybh
from hy_jbxx
order by hybh))
order by hybh


select top 页大小 *
from testtable
where (id not in
(select top 页大小*页数 id
from 表
order by id))
order by id

==================================

mssql

create procedure pr_getarticles —-这里为存储过程名称
@page int,
@pagenum int
as
declare @tablename nvarchar(20)
set @tablename='article' —–表名
declare @idname nvarchar(20)
set @idname='article_id' —–表id名
declare @strsql nvarchar(4000)
declare @topnum int
set @topnum=(@page-1)*@pagenum
set @strsql=n'select top'+ str(@pagenum)+' *
from '+@tablename+'
where '+@idname+'>
(
select isnull(max('+@idname+'),0)
from
(
select top '+str( @topnum)+' '+@idname+' from '+@tablename+' order by '+@idname+'
) a
)
order by '+@idname+"
print (@strsql)
exec(@strsql)
go

mssql

分页方案三:(利用id大于多少和select top分页
语句形式:
select top 10 *
from testtable
where (id >
(select max(id)
from (select top 20 id
from testtable
order by id) as t))
order by id


select top 页大小 *
from testtable
where (id >
(select max(id)
from (select top 页大小*页数 id
from 表
order by id) as t))
order by id

创建分页数据表,同时保存2万条记录

create table [testtable] (
[id] [int] identity (1,1) not null,
[firstname] [nvarchar] (100) collate chinese_prc_ci_as null,
[lastname] [nvarchar] (100) collate chinese_prc_ci_as null,
[country] [nvarchar] (50) collate chinese_prc_ci_as null,
[note] [nvarchar] (2000) collate chinese_prc_ci_as null
) on [primary]
go

sqlite,MysqL

select * from table limitpagesize offset pageindex*pagesize

----------------------------------------------------------------------------------

原文链接:https://www.f2er.com/sqlite/201848.html

猜你在找的Sqlite相关文章