简体   繁体   English

要求有两个限制声明

[英]request with two limit statement

I have this request 我有这个要求

select * from tab where id < 100 order by time desc, type desc limit 1000 OFFSET 0 LIMIT 20

I want to get the 1000 first rows 20 by 20. 我希望得到1000个第一行20乘20。

I have always a syntax error. 我一直有语法错误。

Well, you could use a subquery: 好吧,你可以使用子查询:

select t.*
from (select t.*
      from tab t
      where id < 100
      order by time desc, type desc
      limit 1000
     ) t
order by time desc, type desc
OFFSET 0 LIMIT 20;

But I would just control the number of rows fetched at the application layer. 但我只会控制在应用程序层获取的行数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM