Helpful Information
 
 
Category: Databases
Counting in MySQL

I am working on a little project, I need to make some lookups in a MySQL table.

Table:

ID name type
1 John a
2 Martin a
3 Winston c
4 Mark b
5 Bill b

I then need to make a list of which types there are. EG:

Types:
a
b
c

And I also need to make a count of how many of each type there are EG:

Type Count
a 2
b 2
c 1

I am using PHP3 to interface the MySQL db, how can I do this?

--
Anders

select distinct(type) from table_name;
select type, count(type) from table_name group by type;










privacy (GDPR)