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

Databases Reporting with SQL Ordering, Limiting and Paging Results Limiting Results

Adam Tyler
Adam Tyler
14,865 Points

Why does this need a WHERE clause?

I am getting an error saying I need a where clause, but I don't see why? I have ordered the table then used LIMIT 1 to get the top result, why would I need to do anything else?

1 Answer

The instructions are to find the earliest Science Fiction book in our library. So you have two criteria: a date and a genre. The ORDER BY clause can be used to get the correct date. The WHERE clause is used to filter the genre to just Science Fiction.