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

Stuck on the Limit and Offset code challenge task 2

Here's the chalenge link https://teamtreehouse.com/library/integrating-php-with-databases/limiting-records-in-sql/limit-and-offset and my code Select * from phone_book order by last_name,first_name limit 20 offset 20

5 Answers

Oh im sorry. this is the good solution:

SELECT * FROM phone_book ORDER BY last_name, first_name LIMIT 20 OFFSET 40

Thanks. Now it works!

I'm seeing a different question than you when I click on the link you provided.

But to use your query, have you tried

SELECT * 
FROM phone_book
ORDER BY last_name , first_name 
LIMIT 20, 20

Hi,

SELECT * FROM phone_book ORDER BY last_name, first_name LIMIT 20, 40

No, it didn't work. I'm stuck on the task 2 of this challenge. The task is: Note: We will be writing ONLY the SQL query for this challenge.

Imagine you're developing a Contacts application on a phone. You have a database with a phone_book table. It has the columns, first_name, last_name and phone.

The phone has a technical limitation to show 20 contacts on a screen at a time. Write the SQL query to retrieve the 3rd page of results from the phone_book table. Contacts are ordered by last name and then first name.

Here Is the Correct Answer

SELECT * FROM phone_book ORDER BY last_name, first_name LIMIT 20 OFFSET 40;