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 trialGrady Robbins
8,249 PointsReporting with SQL final assesment: i am thrown off by: LIMIT 0, OFFSET 50. should any rows be returned at all?
To me it seems like this query would return 0 results based on LIMIT = 0, regardless of the OFFSET
2 Answers
KRIS NIKOLAISEN
54,972 PointsIf you are referring to this question:
Can you guess what the following query would do?
SELECT * FROM passport_holders WHERE name = "Lauren" LIMIT 0, 50;
The limit and offset when specified by values separated by a comma are reversed. Here the limit is 50 and the offset is 0. You can read about it in the SQLite documentation
Instead of a separate OFFSET clause, the LIMIT clause may specify two scalar expressions separated by a comma. In this case, the first expression is used as the OFFSET expression and the second as the LIMIT expression. This is counter-intuitive, as when using the OFFSET clause the second of the two expressions is the OFFSET and the first the LIMIT. This reversal of the offset and limit is intentional - it maximizes compatibility with other SQL database systems. However, to avoid confusion, programmers are strongly encouraged to use the form of the LIMIT clause that uses the "OFFSET" keyword and avoid using a LIMIT clause with a comma-separated offset.
Grady Robbins
8,249 Pointsthanks, Kris Nikolaisen.