Iamlaosong
do software development often and database dealings, will use the SQL language, no one can not avoid using count this function to count the number of record rows, count (1) and COUNT (*) function is the same, all count the number of rows . The 1 here does not mean the first field, but rather a constant, you can actually think of a field in a table, the value of this field is fixed to 1,count (1), that is, how many 1 is calculated. Similarly, COUNT (2), can also, get the value exactly the same, count (' x '), count (' Y ') is all yes. * denotes all fields, equivalent to all fields connected together, including rowID,count (*) counts all records.
Select COUNT (*) from Song_temp t;select count (rowid| | t.mail_num| | T.descrip) from Song_temp t;
you can change the * to a field name, which is Count (field name) or multiple field names can be joined together, but note that this notation only counts the number of records for this field or non-null values for these fields, and the null value is not counted (other functions such as AVG, SUM also exclude null values).
with C ount (field name) Also note that if the field values are duplicated, the number of records will be counted repeatedly, if you need to count the number of different values, you need to use Count (distinct field name), for example, suppose there is a person table PP, There is a field that is "gender", as follows (no gender is entered in the last line):
Name Sex
Zhang Sanfeng Male
Zhang Mowgli Man
Zhou Zhijo Women
Zhao Women
The East is undefeated
Select count (Gender) from PP;
for the above table, the result of count (1) and COUNT (*) is the same, which is 5;soCOunt (gender) willstatistics on the number of people who entered the sex, should be 4,Count (Distinct sex) will count several genders, and the null value without sex is not as one, the result should be 2.
Instance of Count function for SQL