hamedghaderi — 2013-01-18T09:13:55-05:00 — #1
I have a table with 37 posts and now I want to select every 10 post per page
Is there any approach to limit items between interval numbers?
SELECT name FROM posts LIMIT(10-20)
kylewolfe — 2013-01-18T09:36:51-05:00 — #2
What your referring to is pagination I believe.
LIMIT 10 will return 10 records, when using a second argument, LIMIT 0,10 for example, will return 10 records, starting at row 0. The first argument will become your variable depending on what page you are on. For page two, you would use LIMIT 10,10, page three LIMIT 20, 10.
r937 — 2013-01-18T09:41:23-05:00 — #3
"starting at row 0" isn't quite right
it's actually an offset, which i prefer to describe as "the number of rows to skip over"
so LIMIT 20,10 doesn't start at row 20, it skips over 20 rows