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

PHP Integrating PHP with Databases Limiting Records in SQL LIMIT and OFFSET

Cannot answer PHP Limit question correctly

I need to display the second page, items 11-20, but for some reason it keeps telling me I am getting it wrong. The directions are as follows:

"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."

Source code (Only had to type SQL code):

SELECT title, author, genre, first_published

FROM books

ORDER BY title

LIMIT 10, 10

Alternatively:

SELECT title, author, genre, first_published

FROM books

ORDER BY title

LIMIT 10 OFFSET 10

I have tried this and many other combinations, and gotten nowhere.

1 Answer

It appears the checker wants you to use SELECT *. Although not in the instructions there is also an id column. That with your second SQL statement will work.

Thank you. I suppose the directions were not clear enough- they should have said that there was an id column. If any staff are looking at this, please update the instructions.