3

I have 100 rows in my DB. I'm trying to execute select query but I want to skip the first 10 rows (i.e. I want rows in range 11-20).

How can I do this?

1
  • Study Limit offset and try to search before posting the question! Commented Oct 14, 2018 at 14:33

2 Answers 2

11

The raw SQL is like:

SELECT * FROM table LIMIT 10 OFFSET 10

In SqlAlchemy language it's like:

Table.query.limit(10).offset(10).all()
Sign up to request clarification or add additional context in comments.

3 Comments

This is SQL, not SQLAlchemy.
result = Doctors.query.all() - it's my query but this query fetchs all records. Can you write your query in this format? Thatns.
This is wrong, it should be Table.query.limit(10).offset(10).all()
3

You can use limit() and offset(), like this:

foos = session.query(Foo).offset(10).limit(10)

Which will construct a query like this:

select * from foos offset 10 limit 10

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.