皇家国教骑士团第几集:SQL查询语句问题高手快来帮帮忙啊!!!

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 01:14:46
比如 用查询语句 select * from table1 where 姓名='111'
查询出来的数据有20条 让他显示出前3条可以用select top 3 * from table1 where 姓名='111'
问? 有没有查询语句 让他显示出第3到第4条的数据或任意那几条数据呢?

select top m * from table where id notin (select top n-1 id from table)

应该是这个吧,id为主键

就我所知好象sql没直接提供这中语句
不过你可以通过asp进行处理啊

或则你可以通过 select from where 语句来定位记录啊

sql="select 10 * from table1 where 姓名='111' "
rs.open ,sql,conn,1,1
i=1
do while not rs.eof
if i=3 or i=4 then
response.writ rs("yourstr")
end if
rs.movenext
i=i+1
loop

rs.close
set rs=nothing
明白没

我不知道有没有,但是常用的方法应该是嵌套查询语句,先用top查出前四条,再用嵌套select语句取前4条里的后2条,就是你要的3,4条。
同理,要查任意一条,比如第9条吧,先用查出前9条,再用嵌套select语句取最后1条就行了。