THE WORLD'S LARGEST WEB DEVELOPER SITE

MySQL COUNT() Function

❮ MySQL Functions

Example

Return the number of products in the "Products" table:

SELECT COUNT(ProductID) AS NumberOfProducts FROM Products;
Try it Yourself »

Definition and Usage

The COUNT() function returns the number of records in a select query.

Syntax

COUNT(expression)

Note: If a record in the expression contains a NULL value, it is not included in the COUNT() calculation.

Parameter Values

Parameter Description
expression Required. A field or a string value

Technical Details

Works in: MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23

❮ MySQL Functions