Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases

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,623 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
MOD
Jason Anders
Treehouse Moderator 145,623 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.