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

Development Tools Database Foundations Reading Data from Databases with SQL Limiting the Result Set

Noah Schill
Noah Schill
10,020 Points

Code 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

I wans't giving the solution, it was just an example. Try to understand how LIMIT works. I think it should be 11, 30

Noah Schill
Noah Schill
10,020 Points

No dice :(.

I thought the second argument would be 19, because they wanted a yield of 19 results (30-11).

Let me try

Ok, 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
Noah Schill
10,020 Points

Thanks Omar! Imo it's very unintuitive that they order it like that xP. Thanks again!

SELECT * FROM movies LIMIT 20 OFFSET 10;

Stephen Moss
Stephen Moss
2,285 Points

I 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!

Having 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.