asp网页设计中SQL语句选取某个区间的记录怎么编写

2024-12-27 04:56:33
推荐回答(5个)
回答1:

select top 8 * from 表 where 主键 not in (select top 1 主键 from 表)

在MS SQL中可以这样:
select top 200 * from TabelA order by MyKey
where MyKey not in
(select top 100 MyKey from TableA order by MyKey)
前面的101-200条记录就出来了。

回答2:

select top(8) * from nsort where id not in(select top(8*(1-1) ) id from nsort
从第9条开始时 把(1-1)换成2-1 在后面(3-1) 以此类推

回答3:

select top 8 * from nsort order by nsort_id desc 这个是取前8条的

select * from nsort where not in(select top 8 * from nsort order by nsort_id desc) order by nsort_id desc 这个是第九条之后的。。。

回答4:

查询1-8条
select top 8 * from nsort order by nsort_id desc

查询第9条以后
select * from nsort
where nsort_id not in
(select top 8 nsort_id from nsort order by nsort_id desc)

回答5:

sql="select top 8 * from nsort order by nsort_id desc
sql="select * from nsort order by nsort_id desc where recno()>8