roverred
roverred

Reputation: 1921

Mysql & php : Getting the latest X posts, then the next X latest, and so forth

For example, Facebook loads the latest X wall posts, and then if the user scrolls down it loads the next X posts after.

I can see how you can get the first latest 10 wall posts. Something like:

SELECT * FROM wall_posts ORDER BY DATE DESC LIMIT 10

This would return the 10 latest posts. But what if I want the next 10 latest after the first 10, that is the latest 10-20 posts? Thanks.

Upvotes: 1

Views: 37

Answers (1)

fthiella
fthiella

Reputation: 49089

LIMIT takes one or two arguments. When two arguments are specified, the first one is the offset and the second one is the number of rows to return:

SELECT * FROM wall_posts ORDER BY DATE DESC LIMIT 10, 10

Upvotes: 2

Related Questions