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

Get the 11th to 30th movie from the movies table. (Again no need to order the results). I am struggling with LIMIT clau

Get the 11th to 30th movie from the movies table. (Again no need to order the results). I am struggling with this question because my answer is :

SELECT * FROM movies LIMIT 10 OFFSET 10; Its wrong what could be problem..?

3 Answers

Alfred Angkasa
Alfred Angkasa
2,413 Points

Hello, I will try to answer your question. Correct me if I'm wrong.

Depends on your table structure.

lets say movies have a column call moviesNumber (int) as PK, moviesTitle varchar(100)

//moviesNumber //moviesTitle 1 Fast & Furious 1 2 Fast & Furious 2 ... n Fast & Furious n

if you only want to select by moviesNumber : "select * from movies where moviesNumber between 11 and 30" if you want to use limit : "select * from movies limit 11, 20" or use yours "SELECT * FROM t_movies LIMIT 10 OFFSET 10"

limit means you only want to show 10 records, offset mean start from 10

SELECT * FROM movies LIMIT 10 OFFSET 10,20;
TaJuanna Williams
TaJuanna Williams
26,697 Points

Answer: select * from movies limit 10, 20;