Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的数据库中有 100 行。我正在尝试执行选择查询,但我想跳过前 10 行(即我想要 11-20 范围内的行)。
我怎样才能做到这一点?
原始 SQL 如下所示:
SELECT * FROM table LIMIT 10 OFFSET 10
在 SqlAlchemy 语言中,它就像:
Table.query.limit(10).offset(10).all()
您可以使用limit()和offset(),如下所示:
foos = session.query(Foo).offset(10).limit(10)
这将构造一个这样的查询:
select * from foos offset 10 limit 10