SQL查询指定条数记要
SQL查询指定条数记录
select top 记录数 ID,field1,field2,....... FROM TableName WHERE 查询条件and ID not in(select top N ID FROM TableName WHERE 查询条件) |
1 楼
lym6520
2008-12-26
不错哦,好用啊!
2 楼
姜太公
2008-12-27
效率太低了。
不能有效利用索引
不能有效利用索引
3 楼
lym6520
2009-01-15
看看这个怎么样,,呵呵
sql 分页索引:
例:
select TOP 3 *
from (select (Row_Number() over (order by FWriteTime desc)) as RowIndex,* from table where id = '0B82E99F-BA1F-473B-88B5-F66316024432') A
where RowIndex > (3*(1-1))
格式:
select TOP 显示记录数 *
from (select (Row_Number() over (order by time desc)) as RowIndex,* from table_name where 条件表达式) A
where RowIndex > (显示记录数*(当前索引页-1))
sql 分页索引:
例:
select TOP 3 *
from (select (Row_Number() over (order by FWriteTime desc)) as RowIndex,* from table where id = '0B82E99F-BA1F-473B-88B5-F66316024432') A
where RowIndex > (3*(1-1))
格式:
select TOP 显示记录数 *
from (select (Row_Number() over (order by time desc)) as RowIndex,* from table_name where 条件表达式) A
where RowIndex > (显示记录数*(当前索引页-1))