Note 1 For mysql count distinct null: An example is used to explain the problem. Now another database table is hello. The table content is as follows: www.2cto.com id name 1 Null2 Null3 Null4 Null5 Null hello table has two fields: id and name, name is null. The first SQL statement www.2cto.com: SELECT COUNT (id) FROM hello; query result: 5, correct. The second SQL statement: SELECT COUNT (*) FROM hello; query result: 5, correct. Article 3 SQL: SELECT COUNT (name) FROM hello; query result: 0, error. Article 4 SQL: SELECT COUNT (DISTINCT id, name) FROM hello; query result: 0, error. 2. Causes of errors in the second and third SQL queries: 2.1 COUNT (), MIN (), and SUM () ignore NULL values. 2.2 The exception to this is COUNT (*), which counts rows and not individual column values. 2.3 For example, the following statement produces two counts. the first is a count of the number of rows in the table, and the second is a count of the number of non-NULL values in the age column: mysql> select count (*), COUNT (age) FROM person;