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 trialCaleb Newell
12,562 PointsSQL limit
In a library database there's a books table. There's a title, author, genre and first_published column. The library database is connected to a website displaying 10 books at a time, sorted by the title alphabetically. Write a query to bring back the second page of results. Please retrieve all columns of information.
3 Answers
Steven Parker
231,269 PointsThe ORDER BY clause is what you would use to meet the requirement in the instructions to display the books "sorted by the title alphabetically".
If you need a refresher, it was covered in the Retrieving Results in a Particular Order video.
Also, if this is to be the second page of results, the OFFSET should be the same as the LIMIT.
Jonathan Grieve
Treehouse Moderator 91,253 PointsORDER BY
is how you get your alphabetical listing of results.
You need to choose the correct column to order the data by. Also be aware that SQL is quite picky sometimes about where a keyword should go in a statement. Also, what are the values you put into the LIMIT and OFFSET keywords? Where does the cutoff happen and do they return 10 results as required?
Good luck with it. Keep trying and all this will stick eventually. :)
Saichand Pullepu
11,905 PointsSELECT * FROM books ORDER BY title LIMIT 10 OFFSET 11;
Keungil Seo
5,570 PointsSELECT * FROM books ORDER BY title ASC LIMIT 10 OFFSET 10
Caleb Newell
12,562 PointsCaleb Newell
12,562 Pointswhat i have so far is,
SELECT * FROM books LIMIT 10 OFFSET 11;
It says I need an ORDER BY in there but I don't understand. Any help?