且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何根据字段值选择行范围-MySQL

更新时间:2023-01-21 09:04:01

您可以使用子查询获取最大值,然后仅使用where子句:

You can use a subquery to get the maximum and then just use a where clause:

select t.*
from t cross join
     (select max(revs) as maxrev from t) x
where t.revs >= x.maxrev - 100000;

我强烈建议您在revs上建立索引.

I would strongly advise you to have an index on revs.