我需要在网页上编写寻呼机代码,通常使用 mysql 是 SELECT with LIMIT 60, 20
的简单解决方案,这意味着从 60 个位置选择 20 行。
现在我正在使用 SQL Server,但应该解决这个问题 - 我知道 TOP 语法不合适,我也听说过 SQL Server 中的 ROW_NUMBER()
函数,但是我发现的示例不够清楚 - 请在测试表上提供帮助,例如“汽车”以简单地
select * from cars limit 20, 10
最佳答案
ROW_NUMBER() 不能在您的 where 子句中,因此您必须使用单独的选择:
select *
from (select row_number() over (ORDER BY cars.CarId) as Row, *
from cars
) temp
where Row between 20 and 29
关于sql - mysql limit x, y 等同于SQL Server l?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6578643/