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!

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


Expected 5 books, returned 0 --- What am I doing?

So, the title basically sums it up. Here is a link to the challenge. I'm not sure what I was doing wrong in my code, so if someone could just give me an idea on how they would do it, I would really appreciate it! It is the first task that I'm having trouble with.

Thanks! ~ Gabriel

Jason Anders
Jason Anders
Treehouse Moderator 145,855 Points

Hey Gabriel, The link is missing. Could you re-post it for us, please?

Sure, here is the link again: (https://teamtreehouse.com/library/reporting-with-sql/ordering-limiting-and-paging-results/limiting-results) The challenge has to do with ordering results and LIMTING the number of returned results. I'm having trouble with task 1 right now. Here is my code so far:

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

~ Thanks for your help!

2 Answers

Jason Anders
Jason Anders
Treehouse Moderator 145,855 Points

Hi Gabriel,

You're really close with your query, except you are missing which genre you want for the WHERE clause. The rest of the query is correct.

And just a note: you don't need the ASC if you don't want. SQL sorts ascending order by default. Some people use it and some people don't. It's really up to you. I just want to point that out in case you see that down the road. I personally don't use it (less code to type) :)

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

Keep Coding! :dizzy:

Oh, I was closer than I thought! Thank you so much for your help!

Gabriel, As Jason mentioned, we need to see your code, what the challenge is, or more information on the specific task that you're having trouble with in order to help you.