Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

count
count
2,142 Points

Question about the "Limiting The Results" test in the SQL deep dive

The test question is:

"Get the 101st to 200th actor from the actors table. (No need to use any ordering)."

The answer is:

SELECT * FROM actors LIMIT 100, 100;

Wouldn't the answer be

SELECT * FROM actors LIMIT 100, 99;??

This would return the 101st to 200th actor, where as the Offset of 100 returns the 101st to 201st actor.

Or am I missing something in the wording?

1 Answer

There are 100 rows between row #101 and row #200. Returning 99 rows would give you rows #101 through #199.

Take a smaller example to see why that is true. For instance, there are 10 numbers (not 9) if you count from 11 to 20.

count
count
2,142 Points

DOH! I was subtracting the lines from each other instead of actually counting it out. That makes sense now though, thank you Ben :)