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 Limiting Results

Alexandra Washick
Alexandra Washick
6,699 Points

WHERE clause and ORDER BY?

This first question has me completely stumped. We're being asked to write a query to select all columns from the book table and display only the first five books in the fantasy genre, ordered by the oldest publication date. Here is what I have as my query:

SELECT * FROM books WHERE genre = "Fantasy" ORDER BY first_published ASC LIMIT 5;

This apparently isn't correct but from everything I'm finding online to help me figure this out, it should be? What am I missing?

Stephen Hood
Stephen Hood
692 Points

Hi Alexandra - I don't know if Treehouse "fixed" whatever was causing your issue, but I pasted that SQL into the challenge and it worked fine. Is it still not working for you?

2 Answers

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

Same as Stephen Hood said, I copied what you've posted here exactly and pasted it into the first challenge and it worked great for me. Maybe refresh and try again, make sure it's exactly what you wrote here in your post. SQL is very particular and our Code Challenges are even more particular with what they want! 😃

Great job figuring out the query!

Alexandra Washick
Alexandra Washick
6,699 Points

Well, I'm likewise not sure what fixed the issue, but like others said, today I copy and pasted the code I wrote here into the challenge and it finally accepted it! Not sure why it wouldn't do it the other day, but this was a good confidence boost to know I had it right all along!