1

I was quite curious to see how one could get the records from n to kth. I don't know if i missed it or not, but going through the docs didn't provide favorable to me.

I'm not saying i want the records where id is between 5 - 10, but the records between 5 - 10. How does one go about this?

1 Answer 1

5

You should use limit and offset:

Client.order("id ASC").limit(5).offset(5)
1
  • You should also explicitly sort: Client.order("id ASC").limit(5).offset(5) The ordering may sometimes be correct without it but that's not guaranteed by e.g. Postgres. (See docs.) Seems the same applies to MySQL.
    – Henrik N
    Dec 7, 2014 at 15:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.