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 trialBrian Jemison
3,832 PointsWhy am I being told there is a problem with the syntax in my query?
On one of the Reporting with SQL challenge tasks I am told to create a query to obtain the first 5 books from the "Fantasy" genre organized the release, with the oldest listed first. I can't figure out what the problem is.
4 Answers
Umesh Ravji
42,386 PointsHi Brian, I'm going to simplify the structure of a query a little, but it should be plenty to point out how it should go. You have all the right stuff in your query, it's just not in the right place.
SELECT [columns] FROM [table] WHERE [conditions] ORDER BY [columns] LIMIT x
Brian Jemison
3,832 PointsUmesh,
Thank you for the clarification :)
james south
Front End Web Development Techdegree Graduate 33,271 Pointswhat is your code?
Brian Jemison
3,832 PointsHi James,
Here is the query I tried submitting
SELECT * ORDER BY first_published ASC FROM books WHERE genre="Fantasy" LIMIT 5
Brian Jemison
3,832 PointsSELECT * ORDER BY first_published ASC FROM books WHERE genre="Fantasy" LIMIT 5
james south
Front End Web Development Techdegree Graduate 33,271 Pointsthe order by goes later in the code, right before limit i think. also if it asks for certain columns, like title, using the universal selector (*) will probably cause an error. so if they just wanted the titles, i think it would be something like:
SELECT title FROM books WHERE genre="Fantasy" ORDER BY first_published ASC LIMIT 5
Brian Jemison
3,832 PointsJames,
Thank you so much for your help!
Umesh Ravji
42,386 PointsUmesh Ravji
42,386 PointsShow us what you have written :)