wlbk.net
当前位置:首页 >> 数据库查询5到10 >>

数据库查询5到10

先排序,然后再选5-10行的数据.

select top 5 * from (select top 10 * from table order by id) table order by id desc

select * from (selct top 5 * from (select top 10 * from table1 order by id) a order by id desc) b order by id

set rs = conn.execute ("select * from abc order by id desc") rs.movelast rs.moveprevious response.write rs("aaa") 先把记录移到最后,再往后移一条记录就是倒数第二行.

select top 1 * from table where id in (select top 50 id from table order by id desc)

'试试,子查询后面加一个别名t:mesql = "select top 5 * from ( select top " & sqltop & " * from " & Ph & ") t where 用户名='1'"

SELECT top 10 * FROM 表 where id not in (select top 5 id from 表)

select top 5 * from (select top 10 * from squarer order by id asc) a order by id desc 先asc取前10条 再倒着取(desc)这个结果的前5条在我这里测试通过

标准sql语句并不支持随机查询,没有随机函数.如果真需要这个功能,可以考虑写一个存储过程或者函数实现.

可以实现、嵌套查询,第一次直接查前面5条,第二次查前面10条,倒序一下再查询前面5条、依次类推、 zhangcuibao 的方法可以再mysql用,在mssql就不行了、

网站首页 | 网站地图
All rights reserved Powered by www.wlbk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com