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!

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


Carter Stahl
Carter Stahl
3,767 Points

Ordering the Result Set Challenge

What am I doing wrong?! Get the 11th to 30th movie from the movies table. (Again no need to order the results).

'''SELECT * FROM movies LIMIT 10 OFFSET 1;'''

2 Answers

Peter Ramsing
Peter Ramsing
16,814 Points

Try this:


By setting your OFFSET to 10, that means it will start the count at 11 and then you are counting 20 units, thus this will display the movies between 11 and 30.

Robert Bojor
Robert Bojor
Courses Plus Student 29,439 Points
SELECT * FROM movies LIMIT 10, 20

should do the trick... since the limit is just like an array, 0 indexed, by specifying 10 as the first parameter you start from the 11th entry and the second parameter is the slice size, in this case 20, to get to the 30th entry and include it as well in the result.

its working thanks

I'm a bit confused. This works, but I'm still struggling with the concept.

Since it's zero-indexed, one would think that setting it to 10 would have it go up to 9. How does setting it to 10 make it select the first eleven?

If I start typing numbers:

0123456789 (that is 10 numbers, starting at zero).

If someone could explain or offer some insight, I would greatly appreciate :)