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 trialGregory Ledger
6,116 PointsOffsetting Actors question
I wasn't sure what the note meant
SELECT * FROM actors LIMIT 20 OFFSET 699; produced actors with ids from 701-720
SELECT * FROM actors LIMIT 20 OFFSET 700; produced actors with ids from 702-721
I think the second one is right, but its a guess. How does this work?
2 Answers
Jacob Herrington
15,835 PointsSELECT * FROM actors LIMIT 20 OFFSET 699; --produced actors with ids from 701-720
SELECT * FROM actors LIMIT 20 OFFSET 700; --produced actors with ids from 702-721
In MySQL, the LIMIT
clause "limits" the number of records you will receive in your result set. So setting LIMIT
to 20 will return only 20 records.
The OFFSET
clause "offsets" the position from which your query will begin adding records to the result set. OFFSET 699
means start at the record in position 699. Usually this is used in conjunction with ORDER BY
to select only records that meet a specific criteria.
Gregory Ledger
6,116 PointsThank you. I think I understand now.
Jacob Herrington
15,835 PointsJacob Herrington
15,835 PointsHey Gregory -- for future reference, you can link the challenge you are stuck on by using the Get Help button. Just so we can check the solutions we give you against the actual challenge!