您好我有一个mysql查询,它会计算表中的行以进行分页,但我还需要计算并按另一列进行分组。
我可以让查询对记录进行分组并显示正确的结果,但它会阻止分页的工作。
这是我的查询
SELECT
COUNT(*) as num,
COUNT (search_term)
FROM $tableName
WHERE client_id = '{$client_id}'
AND search_term IS NOT NULL
AND search_term != ''
GROUP BY search_term
任何指针都将不胜感激
答案 0 :(得分:0)
尝试
SELECT COUNT(*) as num1, COUNT (search_term) as num2
FROM $tableName
WHERE client_id = '{$client_id}'
AND search_term IS NOT NULL
AND search_term != ''
GROUP BY search_term
LIMIT $page , $limit
您需要提供$page
值作为当前页码,$limit
将是一页包含的限制