MySQL provides five aggregate functions that enable you to summarize table data without retrieving every row. By using these functions, you can find the total number of rows in a dataset, the sum of the values, or the highest, lowest, and average values.
The COUNT() function counts values in a query. You can perform a count on a single column by putting the column name in parentheses. More commonly, though, you use COUNT(*) to return the total number of rows returned by a query.
The following example counts the total number of orders that have been placed in the sample database:
mysql> SELECT COUNT(*) -> FROM orders; +----------+ | COUNT(*) | +----------+ | 7 | +----------+ 1 row in set (0.00 sec)