The method of counting the number of groups by mysql
This article mainly introduces the method of counting the number of groups by mysql, which has certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.
Mysql counts the number of groups: 1, count the total number of records [SELECT count (*) FROM table name WHERE condition]; 2, count the number of records in each group [SELECT count (*) FROM table name WHERE condition GROUP BY id].
The method of counting the number of groups by mysql:
SELECT count (*) FROM table name WHERE condition
What is found in this way is the total number of records.
SELECT count (*) FROM table name WHERE conditional GROUP BY id
In this way, the count will be the number of records in each group.
How do I get the total number of records for the second sql statement?
It is as follows:
Select count (*) from (SELECT count (*) FROM table name WHERE condition GROUP BY id) a; SELECT count (*) FROM (SELECT COUNT (*) FROM `papa_stadium_goods_storage_ record`WHERE `ctime` > = 1474560000 and `ctime`