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 trialZachary Wheeler
1,157 PointsVery First Reporting SQL Challenge Question
SELECT * FROM books ORDER BY first_published LIMIT ASC 5;
It asks us to input a code querying the first 5 in ascending order, but it says i'm missing WHERE. I don't know where to put the WHERE. Can you help me?
Zachary Wheeler
1,157 PointsThanks, I entered in the info and now it is saying that I didn't request 5? Here is what I have:
SELECT * FROM books WHERE genre ORDER BY first_published ASC LIMIT 5;
Let me know what I can fix. Thanks
3 Answers
Steven Parker
231,126 PointsYou didn't finish your WHERE
clause.
I see that you started to write it, but you didn't finish testing for the Fantasy genre.
SELECT * FROM books WHERE genre = "Fantasy" ORDER BY first_published ASC LIMIT 5;
The incomplete test was rejecting every genre, producing 0 books instead of 5.
Zachary Wheeler
1,157 Pointsoh that makes sense now. Thanks so much!
imadghazi
2,746 PointsSELECT * FROM books WHERE genre="Fantasy" ORDER BY first_published ASC LIMIT 5;
Leon Segal
14,754 PointsNice answer Imad - concise. I like it.
Steven Parker
231,126 Points...and a loooong one, with a 6-month delay time.
Leon Segal
14,754 PointsLeon Segal
14,754 Pointsfirst, there is a mistake in your code, no biggie but:
SELECT * FROM books ORDER BY first_published ASC LIMIT 5;
second, the question is asking for fantasy books.
Sql queries are generally in this format (I find it easier to write my queries in this layout):
So the answer would be something like:
I will leave the rest for you to fill in ;)