查询员工总数:
mysql> select count(*), count(fnumber) from t_employee;
+----------+----------------+
| count(*) | count(fnumber) |
+----------+----------------+
| 8 | 8 |
+----------+----------------+
1 row in set
NULL值对COUNT函数的影响:
mysql> insert into t_employee(fnumber,fage,fsalary) values('IT002',27,2800);
Query OK, 1 row affected
mysql> select * from t_employee;
+----------+-------+------+---------+
| fnumber | fname | fage | fsalary |
+----------+-------+------+---------+
| DEV001 | Tom | 25 | 8300 |
| DEV002 | Jerry | 28 | 2300.8 |
| HR001 | Jane | 23 | 2200.88 |
| HR002 | Tina | 25 | 5200.36 |
| IT001 | Smith | 28 | 3900 |
| IT002 | NULL | 27 | 2800 |
| SALES001 | John | 23 | 5000 |
| SALES002 | Kerry | 28 | 6200 |
| SALES003 | Stone | 22 | 1200 |
+----------+-------+------+---------+
9 rows in set
mysql> select count(*), count(fnumber),count(fname) from t_employee;
+----------+----------------+--------------+
| count(*) | count(fnumber) | count(fname) |
+----------+----------------+--------------+
| 9 | 9 | 8 |
+----------+----------------+--------------+
1 row in set