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 trialAdriano De Oliveira
5,653 Pointsi would like some help topic database paging through results!!!!!!!!!!!!!!!!
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.
topic : paging through result, challenge one!
2 Answers
Adriano De Oliveira
5,653 Pointsthanks!!
Adriano De Oliveira
5,653 PointsHi,Steven ! I would like to ask you how do you post code colourful, with red, green,blue ??????????????
Steven Parker
231,248 PointsWhen you format your code using the instructions in the Markdown Cheatsheet (you'll find it below the text entry area ) and you include your language in the opening quote line, the system applies syntax highlighting for you.
Also, when you select a "Best Answer" to a question, it should be the answer that most directly addresses the question you asked and/or the one that helped you the most. Other readers my rely on your choice to help determine a good reply from a bad one.
Steven Parker
231,248 PointsIs your issue just the paging?
I'm going to assume you're comfortable with the rest of the query instructions. So if you are displaying 10 entries at a time, then your LIMIT
is 10. And if you want to see the second page, that would mean you want to skip the first page of 10, so your OFFSET
would also be 10.
Does that answer your question?
In future, to enable the most complete and accurate analysis, always post your code along with a link to the course page.
Adriano De Oliveira
5,653 Pointshello Steven! Can you check my code because is not working! thanks.
Steven Parker
231,248 PointsExamining this code:
Select*From order by limit 10 offset 10<skipped rows>;
- you forgot to put the table name after
FROM
- you forgot the sort criteria after
ORDER BY
- you wrote "
<skipped rows>
" which is not a valid comment (as a comment it would be "/*skipped rows*/
") - it would be good practice to have a space on either side of the asterisk
SELECT * FROM books ORDER BY title LIMIT 10 OFFSET 10/*skipped rows*/;
Adriano De Oliveira
5,653 PointsAdriano De Oliveira
5,653 PointsSelect*From order by limit 10 offset 10<skipped rows>;