Hi I have a mysql query which counts the rows in the table for pagination, but I also need to count and group by another column.
I can get the Query to group the records and show correct results, but it stops the pagination from working.
This is my Query
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
Any pointers would be appreciated
Try like
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
And you need to give $page
value as the current page number and $limit
will be the limit that one page contains
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.