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 Database Foundations Reading Data from Databases with SQL Limiting the Result Set

Hi there, Can anyone help me with this question: Get the 101st to 200th actor from the actors table.

I don't know how to write the query for this question: Get the 101st to 200th actor from the actors table. (No need to use any ordering).

Thanks in advance

3 Answers

Joseph Anderson
Joseph Anderson
10,617 Points

You can also forgo using the OFFSET keyword and run the following:

SELECT * FROM actors LIMIT 100, 100;

Just remember that the first number is the OFFSET and that the count starts at 0.

Sobin Sebastian
Sobin Sebastian
5,348 Points

this is also correct answer: SELECT * FROM actors LIMIT 100, 100;

Ryan Ruscett
Ryan Ruscett
23,307 Points

There are a couple ways to get this, but for me it's all about the between operator.

http://www.w3schools.com/sql/sql_between.asp

I would give you the answer but it would just be repeating the link. Let me know if that solves your issue.

Thanks!

Thank you so much Ryan, but that was not the required solution:$

It required to use the keyword LIMIT

Finally, I re-watched again the video, and the solution (for everyone else who doesn't know this answer) is:

SELECT * FROM actors LIMIT 100 OFFSET 100;

Thanks for your time