sql 分頁技術

2021-05-24 23:24:31 字數 1340 閱讀 1792

--create table tb_page

--(--    pid            int primary key identity(1,1),

--    pname        varchar(100)

--)--drop table tb_page

--declare

--@count        int,

--@num        int,

--@sql        varchar(max),

--@pname        varchar(100)

--select @count=1000;

--select @num=1;

--while(@num<@count)

--begin

--    select @pname='第'+convert(varchar(100),@num)+'頁';

--    select @sql='insert into tb_page (pname)values('''+@pname+''')';

--    select @num=@num+1;

--    exec(@sql)

--end

--select * from tb_page

--select * from

--    (select top 100 * from

--        (select top 299 * from tb_page order by pid asc) tb1) tb2

--order by pid asc

--create procedure proc_page

--    @page        int,

--    @pcount        int

--as

--begin

--    select row_number() over(order by pid asc) as num, pid,pname

--    from

--        (

--            select row_number() over (order by pid asc) as rownum, *

--            from tb_page

--        ) as t

--    where t.rownum> (@page-1)*@pcount  and t.rownum<= @page*@pcount

--end

--go

--drop proc proc_page

--exec proc_page 3,100

sql 分頁 後台分頁技術

select stunumber,stuname,case when stumath 90then 優 when stumath 80then 良 when stumath 70then 中 else 差 end as 數學成績 from tbstudent 第一種用法 case語句就是構造乙個新的...

SQL 資料庫分頁技術

分頁方案一 利用not in和select top分頁 語句形式 select top 10 from testtable where id not in select top 20 id from testtable order by id order by id select top 頁大小 f...

手寫分頁sql 分頁查詢SQL語句

表結構 drop table if exists zhoufoxcn userlist create table zhoufoxcn userlist userid int 10 unsigned not null auto increment,username varchar 45 not nul...