How to use the Count Function in MySql Database

The "count()"function allows us to count the number of row in a certain table or to count some values. Syntax:

Select count(name of the column) from table_name;
-before we do this create the table and add data to it using the following sql sintax: Script:
--first lets drop the table Test (if she exists, if not skip the drop line).Drop table test;create table test (id int,name varchar(20),email varchar(20),salary int,de char(2));--insert values into tableinsert into test values (1,'Eve','[email protected]',1500,'HR'); insert into test values (2,'Jon','[email protected]',2500,'AD');insert into test values (3,'Mike','[email protected]',3000,'AD');insert into test values (4,'Paul','[email protected]',3200,'HR');insert into test values (5,'Mary','[email protected]',1800,'IT');insert into test values (6,'Jane','[email protected]',2200,'IT');
Check the table to see the data and the structure.
SQL
select * from test ;  ID NAME     EMAIL      SALARY DE ---------- -------------------- -------------------- ---------- -- --------   1 Eve     [email protected]    1500  HR   2 Jon     [email protected]    2500  AD   3 Mike    [email protected]    3000  AD   4 Paul    [email protected]    3200  HR   5 Mary    [email protected]    1800  IT   6 Jane    [email protected]    2200  IT
Very good Count() Examples: Example 1:
SQL
select count(*) from test; COUNT(*) ----------   6
-the count() function will count all the rows that the condition/clause will point out to , in our case all of the table rows as our * sign suggests. -we can use condition/clause to be more specific in our count(). Example 2:
SQL
select count(*) from test where DE='IT'; COUNT(*) ----------   2
-this example will count all the persons that work in the IT department. In our case 2 of then do so . Example 3:
SQL
select count(*) from test where salary
2500; COUNT(*) ----------   2
This example will count all the persons that have salaries bigger then 2500 .