similar records count in php?

wissi

New member
hello, i am making a table with 2 fields i.e. name & gender. now, say there are hundreds of enteries in table. now i have made a recordset and want to make a record count for gender. the example is following:

Male (1,054)
Female (4,124)

Pls help me while making this code.
thanks
 
SELECT COUNT(*) FROM table_name WHERE gender='MALE'
UNION
SELECT COUNT(*) FROM table_name WHERE gender='FEMALE'

Can I suggest database tables they should almost always have a primary key like this:
id INT(11) PRIMARY KEY AUTO_INCREMENT NOT NULL

And you should make a field that requires one of two options a BOOLEAN, TINYINT or ENUM.
 
Back
Top