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

Fathima Fas-ha
Fathima Fas-ha
6,847 Points

Reporting with SQL

I couldn't solve this quiz, I need help !! Is there any rules like we should use WHERE clause at the end of SQL statements?

SELECT * FROM books ORDER BY first_published ASC LIMIT 5; This statement says that i'm missing a where clause so i tried like this, SELECT * FROM books WHERE genre="Fantasy" ORDER BY first_published ASC LIMIT 5; it gives a syntax error same as SELECT * FROM books ORDER BY first_published ASC LIMIT 5 WHERE genre="Fantasy" ; I also tried using LIKE keyword ,but i failed ,so help me to solve this quiz Thanks in advance!!

1 Answer

Steven Parker
Steven Parker
229,744 Points

Your second try appears to be correct, I'm not sure why you would have seen an error. Try it again:

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

And "ASC" is optional since it is the default.