您好,欢迎访问一九零五行业门户网

用一条SQL语句取出第 m 条到第 n 条记录的方法

用一条sql语句取出第 m 条到第 n 条记录的方法 取出 记录 --从table 表中取出第 m 条到第 n 条的记录:(not in 版本) select top n-m+1 * from table where (id not in (select top m-1 id from table )) --从table表中取出第m到n条记录 (exists版本) select
用一条sql语句取出第 m 条到第 n 条记录的方法 取出 记录 --从table 表中取出第 m 条到第 n 条的记录:(not in 版本) select top n-m+1 * from table where (id not in (select top m-1 id from table )) --从table表中取出第m到n条记录 (exists版本) select top n-m+1 * from table as a where not exists (select * from (select top m-1 * from table order by id) b where b.id=a.id ) order by id --m为上标,n为下标,例如取出第8到12条记录,m=8,n=12,table为表名,temp为临时表 select top n-m+1 * from table where id>(select max(id) from (select top m-1 id from table order by id asc) temp) order by id asc --找出升序的第m到第n条记录,更为笨拙的办法是 select * from (select top n-m+1 * from (select top n * from 表名 order by id desc) t1 order by id) t2 order by id
其它类似信息

推荐信息