The COUNT() function returns the number of rows in a query.
The COUNT() function is used with MySQL SELECT statement and it is very useful to count the number of rows in a table having enormous data.
SELECT COUNT (expression) FROM tables WHERE conditions;
Let's put these statements into real use.
We've a table named Students in our database that contains the following records:
Now lets Count the number of record from Students Table.
SELECT Count(ROLL_NO) FROM Students;
The above SELECT statement Counts the number of ROLL_NO.
We can count number of rows with where condition.
SELECT Count(ROLL_NO) FROM Students WHERE SUBJECT='JAVA'
The above SELECT statement COUNT row number of SUBJECT is 'JAVA'.