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

Development Tools Database Foundations Reading Data from Databases with SQL Limiting the Result Set

LIMITING

I'm getting unexpected errors in the code challenges. For 1 of 2, I entered:

SELECT * FROM actors LIMIT 100, OFFSET 100; #didn't work but SELECT * FROM actors LIMIT 100, 100; #passed.

Why? It doesn't state a preference for the shorthand and either should work.

For challenge 2 of 2 I entered:

SELECT * FROM movies LIMIT 20, 10; #did not pass and SELECT * FROM movies LIMIT 20, OFFSET 10; # did not pass

This statement, in my head says : limit the display to the 20 rows (rows 11 - 30, indices 10 - 29) AFTER ignoring the first 10 rows (indices 0-9).

What am I misunderstanding?

Thank you, spent way too much time this already!!

1 Answer

For task 1 of 2, your only error with the longhand version of SELECT LIMIT statement is that you've got a comma between LIMIT 100 and OFFSET 100. Without the comma, it should pass.

For task 2 of 2, I think there may be something fishy going on with that Code Challenge. First it denies SELECT * FROM movies LIMIT 20 OFFSET 10, then it accepts it. It was also accepting the answer with a LIMIT 10 and OFFSET 20 for a while.

Don't worry, you're not misunderstanding anything :P I've emailed Support with this Code Challenge issue.

Bryan, Thank you for taking the time on this. It's the Order By segment where he mentioned separating with a comma, so I think I made an assumption there. Many thanks again.