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

Databases Reporting with SQL Ordering, Limiting and Paging Results Review: Ordering, Limiting and Paging Results

Ethan Martin
PLUS
Ethan Martin
Courses Plus Student 1,883 Points

Retrieving Data - SELECT, LIMIT, OFFSET

SELECT * FROM passport_holders WHERE name = "Lauren" LIMIT 0, 50;

Can someone tell me what this will do? The answer key is saying it will bring the first 50 rows with these specifications.

However, I interpreted this differently. I thought it would return "nothing" staring at the 51st entry.

isn't the second value the offset?

What does it mean to LIMIT by 0?

2 Answers

From here

The Limit clause accepts one or two parameters, whenever two parameters are specified, the first is the offset and the second denotes the count whereas whenever only one parameter is specified, it denotes the number of rows to be returned from the beginning of the result set.

So with 2 parameters you'll retrieve 50 records starting at 0 (the first 50)

With one parameter (LIMIT 0) you'll retrieve 0 records