使用表
products(id, title, price, category_id)
如何按标题、价格、category_id、件数过滤产品并使用键集/搜索分页检索第二页?一个页面有 10 个项目
https://blog.jooq.org/2016/08/10/why-most-programmers-get-pagination-wrong/
使用偏移分页的 SQL 将是
SELECT * FROM products
WHERE title like '%search_term%' AND price > 100 AND price < 400 AND category_id=11
ORDER BY price DESC
LIMIT 10 OFFSET 10
Run Code Online (Sandbox Code Playgroud)
结果可以按这个顺序
(id=23, title='Some text', price=354, category_id=11)
(id=41, title='Big text', price=333, category_id=11)
(id=43, title='big big text', price=333, category_id=11)
(id=38, title='A text', price=288, category_id=11)
(id=11, title='text', price=200, category_id=11)
Run Code Online (Sandbox Code Playgroud)