In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to use the count () function of mysql". In daily operation, I believe many people have doubts about how to use the count () function of mysql. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use the count () function of mysql". Next, please follow the editor to study!
In mysql, the COUNT () function can count the total number of record rows contained in the data table, or return the number of data rows contained in the column based on the query results; syntax "SELECT COUNT (*) FROM data table;" or "SELECT COUNT (field name) FROM data table;".
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
The MySQL COUNT () function counts the total number of record rows contained in the data table, or returns the number of data rows in the column based on the query results, using the following two methods:
COUNT (*) calculates the total number of rows in the table, regardless of whether a column has a numeric value or is null.
COUNT (field name) calculates the total number of rows under the specified column, ignoring rows with null values.
Example 1: query the total number of rows in the tb_students_score table
Mysql > SELECT COUNT (*)-> AS students_number-> FROM tb_students_score;+-+ | students_number | +-+ | 10 | +-+ 1 row in set (0.03 sec)
As you can see from the query results, COUNT (*) returns the total number of rows recorded in the tb_students_score table, regardless of the value. The name of the returned total is students_number.
Tip: the way to treat NULL values when calculating totals is that rows with empty values of the specified column are ignored by the COUNT () function, but if you do not specify a column and use the asterisk "*" in the COUNT () function, all records are not ignored.
Example 2: returns the number of products in the "Products" table
Mysql > SELECT COUNT (ProductID)-> AS NumberOfProducts-> FROM Products;+-+ | NumberOfProducts | +-+ | 77 | +-+ 1 row in set (0.03 sec) so far, the study on "how to use the count () function of mysql" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.