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

Databases Reporting with SQL Ordering, Limiting and Paging Results Review: Ordering, Limiting and Paging Results

Madhuri Maddala
PLUS
Madhuri Maddala
Courses Plus Student 793 Points

Obtain the actor records between the 701st and 720th records using only LIMIT and OFFSET

I have trouble solving this query in the workspace. Could you please help me in this?

2 Answers

Jonatan Spahn
Jonatan Spahn
6,362 Points

SELECT name FROM actors LIMIT 20 OFFSET 700;

So you want to return the names from 701 to 720 you LIMIT your returned names to 20 values and you want to start at 701 so you will OFFSET 700 so that the first value you return is 701

Madhuri Maddala
Madhuri Maddala
Courses Plus Student 793 Points

Thank you for the clear explanation. Now changed the query and it working fine.

SELECT * FROM actors ORDER BY id LIMIT 20 OFFSET 699;

This will display all actors with the id of 701 and 720;