这是例子
id | name | year | color
------------------------
1 | john | 1955 | red
2 | mark | 1955 | yellow
.... more than 10K inserts
如果我搜索“ mark”,我将获得约100个结果。我显示了分页的结果(每页15个)。
我想要的是:每页显示15个结果,但在侧面显示“年”和“颜色”的所有不同值,这些值将用作基于所有〜100个结果的过滤器。
将来将有大约100K插入内容和大约20个单元(年,颜色)作为过滤器。
最佳答案
$count = 15;
$offest = $page * $count;
// for the 1-st page $page = 0;
// for the 2-nd page $page = 1;
// for the 3-rd page $page = 2; ......
SELECT name FROM table WHERE name = 'mark'
GROUP BY year, color
LIMIT $offset, $count;
关于mysql - 如何获取搜索结果中的所有列值包括分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33827136/