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

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

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

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

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(@L_403_2@)

from

(

select top '+str( @topnum)+' '+@idname+' from '+@tablename+' order by '+@idname+'

) a

)

order by '+@idname+"

print (@strsql)

exec(@strsql)

go

分页方案三:(利用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

select * from table limitpagesize offset pageindex*pagesize

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

总结

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

如您喜欢交流学习经验,点击链接加入交流1群:1065694478(已满)交流2群:163560250

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值