Prasad Kb
Prasad Kb

Reputation: 1

In PhpMyadmin Count rows issue with mysql

I added below query in phpmyadmin

 SELECT id,u_id,count(u_id) As cnt
FROM  `pager` 
WHERE  type = 'profile' group by u_id

Query Executed.

I got below output showing (0- 30 results) total 24000 records found

I tried same query in different format

SELECT count(u_id) As cnt,id,u_id
FROM  `pager` 
WHERE  type = 'profile' group by u_id

Query Executed. I got below Query Executed Successfully.SHowing just 30 records , No Pagination dropdown.I can't click id and u_id field heading to sort..Someone please help what is the issue..I think both query should execute 24000 records..Please advise

Upvotes: 0

Views: 1040

Answers (1)

Nouman Arshad
Nouman Arshad

Reputation: 593

PhpMyAdmin display default results as per it's settings which you can change from Number of rows : dropdown value in the interface.

If you need to display all your result, then you must add limit clause in your query to display all records

SELECT id,u_id,count(u_id) As cnt
FROM  `pager` 
WHERE  type = 'profile' group by u_id
LIMIT 0, 999999

Otherwise, it will display 30 resuts (or whatever default PhpMyAdmin settings)

NOTE: To sort out the results, add Order by clause in your query then the query would look like following:

SELECT id,u_id,count(u_id) As cnt
FROM  `pager` 
WHERE  type = 'profile' group by u_id
ORDER BY `id` DESC
LIMIT 0, 999999

Hope, it helps you.

Upvotes: 3

Related Questions