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 trialKristin Fitzpatrick
585 PointsWhy is "Limit" not working in query?
I'm working on one of the early Reporting with SQL problems, and I can't figure out why "limit" isn't working: The challenge task is to pull 5 fantasy books, oldest first.
The error message I get on this is "Bummer! Five books were expected." SELECT * FROM books WHERE genre = "fantasy" ORDER BY first_published LIMIT 5;
Shorter queries ending in "Limit 5" work, so I don't know what combination of things is causing the problem in this query. Thanks!
Aside to Treehouse: I understand you may not want to provide an answer key (since there are different ways of querying), but it's frustrating to have all progress blocked due to one wrong answer. Maybe users could be presented with a different question testing them on the same concepts or let them move ahead with 2 out of 3, etc.
2 Answers
Steven Parker
231,236 PointsThe issue is not the LIMIT
but the filter. The challenge said "to obtain the first 5 books in the Fantasy genre...", but your WHERE
clause is comparing "fantasy" (lower-case "f") instead of "Fantasy" (capital "F"). Some databases do case-insensitive comparisons by default, but this one doesn't.
Also, you don't need to be "stuck" at a challenge, you can always skip ahead to the next step using the circles at the top of the video window, or by going back to the course index and picking from there.
Kristin Fitzpatrick
585 PointsAh, OK. Thanks - appreciate the help!