Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of counting the number of groups by mysql

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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`

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report