开发者

How can I "display more" in a list?

开发者 https://www.devze.com 2023-01-10 06:43 出处:网络
like the next 15 values in the ITEMS table sorted by date a开发者_高级运维dded?SELECT column FROM table

like the next 15 values in the ITEMS table sorted by date a开发者_高级运维dded?


SELECT column FROM table
LIMIT 10 OFFSET 10

http://www.petefreitag.com/item/451.cfm mentions OFFSET is supported by both PostgreSQL and MySQL.


Before, you query

SELECT COUNT(foo) AS number_of_elements FROM table;

in order to know how many pages ( CEIL(number_of_elements / elements_per_page) ) you need.


It looks like you need to look at the LIMIT clause:

SELECT    *
FROM      items
ORDER BY  date_added DESC
LIMIT     0, 15;

Then to display the next 15 items, simply change the 0 of the LIMIT clause to 15... then to 30... then to 45... and so on. This is called pagination.

0

精彩评论

暂无评论...
验证码 换一张
取 消