Javatpoint Logo
Javatpoint Logo

MariaDB COUNT() Function

In MariaDB database, COUNT function is used to return the count of an expression.


The COUNT () Function counts only NOTNULL values.


We have a table "Students", having the following data:

MariaDB Count function 1

Count "student_id" from "Students" table:


MariaDB Count function 2

It shows 8 rows of student_id is available in "Students" table.

Now count "admission_date" from "Students" table:


MariaDB Count function 3

It shows only 7 rows of "admission_date" column because 1 field is NULL.

COUNT () Function with Single Expression

Count the number of students where "student_name" is "Ajeet" or "Kanchan".


MariaDB Count function 4

COUNT () Function with Distinct Clause

DISTINCT Clause is used with COUNT () function to prevent duplicate counting. It consists of only original records.


MariaDB Count function 5

It shows only 2 counts because "student_name" Ajeet has duplicate entries in the table.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA