ASP中怎么读取这样的数据?

来源:百度知道 编辑:UC知道 时间:2024/05/21 20:00:59
我知道的是从数据库中读取最前的十条数据的命令是

select top 10 id,topic from news where hidden=1 and c_id=1 order by id desc

那我想读取第11条至20条,那应该怎么在这段话上修改呢?

或者我想读取最后的十条,又该用什么参数呢?

那我想读取第11条至20条:
select top 10 id,topic from news where id not in(select top 10 id from news where hidden=1 and c_id=1 order by id desc ) and hidden=1 and c_id=1 order by id desc

读取最前的十条:
select top 10 id,topic from news where hidden=1 and c_id=1 order by id

读取最后的十条:
select top 10 id,topic from news where hidden=1 and c_id=1 order by id desc

如果你的数据库是mysql

LIMIT是个不错的选择
select * from table LIMIT 5,10; #返回第6-15行数据
select * from table LIMIT 5; #返回前5行
select * from table LIMIT 0,5; #返回前5行

只用sql语句貌似无法实现。
你可以用recordset对象的pagesize来设置页大小。然后进入第几页来读取