1.加索引 2.select * from table where id > (select max(id)-100 from table )
select top 100 * from table where id>(select MAX(id)-100 from table) 哎,思路就是这样 貌似还是要排序
加索引解决不了问题 那个排序可是全表扫描呀, 数据量大简直是灾难 ID是递增的话,可能参考如下, 如果ID加上索引, 当然非常快 select z.* from table as z, (select (max(id) - 100) as BegID from table ) as m where z.ID >= m.BegID order by z.id desc
2.select * from table where id > (select max(id)-100 from table )
哎,思路就是这样 貌似还是要排序
那个排序可是全表扫描呀, 数据量大简直是灾难
ID是递增的话,可能参考如下, 如果ID加上索引, 当然非常快
select z.*
from table as z,
(select (max(id) - 100) as BegID
from table
) as m
where z.ID >= m.BegID
order by z.id desc