Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools

Reading Data from Databases with SQL: Limit and Offset

I am having some trouble understanding limit and offset in the database foundations. I understand it in the examples they give in the video, but in the code challenge it tells me to "Get the 101st to 200th actor from the actors table." I am having trouble processing how to make this work. Could anyone explain and clear this up for me? Thanks!

I'm having trouble with this challenge also. This is what I tried..... "SELECT * FORM actors LIMIT 99, 200;" Can't seem to figure this one out.

Sorry "FROM"

3 Answers

Elliott Frazier
PLUS
Elliott Frazier
Courses Plus Student 9,647 Points

if you could provide the code you've done thus far I would be glad to give you some pointers

One way may be where id > 100 limit 99

"id" is incorrect because there's no column for it. I tried "SELECT * FROM actors WHERE name > 100 LIMIT 99;" This did not work either. Please someone help with this challenge.

Hi Dennis Howell, I see that my original comment may have steered you wrong. This code challenge would like you to use the LIMIT and OFFSET options. The LIMIT option determines how many records to pull and the OFFSET option selects the starting number plus one. Therefore, if you want the first 100 records starting at the 101st record you'd use:

SELECT * FROM actors WHERE LIMIT 100 OFFSET 100

Hope that helps!

Thanks Chris. That clears up a lot. Now I can move on. And also thanks for the swift reply, your the man!