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 trialNoah Schill
10,020 PointsCode challenge: am I deeply confused?
Get the 11th to 30th movie from the movies table. (Again no need to order the results).
SELECT * FROM movies LIMIT 12, 19;
I am choosing 19 as the second argument as there will be a total of 19 results displayed. I am choosing 12 as the first argument (OFFSET) because I want to start from the 12th index (11th result). Where am I wrong?
4 Answers
Omar Sanseviero
8,770 PointsI wans't giving the solution, it was just an example. Try to understand how LIMIT works. I think it should be 11, 30
ashok bishnoi
10,160 PointsSELECT * FROM movies LIMIT 20 OFFSET 10;
Stephen Moss
2,285 PointsI had the same problem. Checked it against my database and the query SELECT title FROM movies LIMIT 20 OFFSET 10; and it was spot on. The quiz was shown as wrong. Bad!
Michael King
874 PointsHaving the same issue with the quiz with regards to LIMIT & OFFSET - similar to Stephen Moss, checked on database and query returns expected records. Agree with above comments, unintuitive.
Noah Schill
10,020 PointsNoah Schill
10,020 PointsNo dice :(.
I thought the second argument would be 19, because they wanted a yield of 19 results (30-11).
Omar Sanseviero
8,770 PointsOmar Sanseviero
8,770 PointsLet me try
Omar Sanseviero
8,770 PointsOmar Sanseviero
8,770 PointsOk, sorry. The first number is the offset (the first number), the second number is the number of results. SELECT * FROM movies LIMIT 10,20 You start in the index 10, and you want 20 results.
Noah Schill
10,020 PointsNoah Schill
10,020 PointsThanks Omar! Imo it's very unintuitive that they order it like that xP. Thanks again!