i have a table how do i SELECT so it will be grouped by section and count how many names in that gender TIA.
Sounds like you want to group this by both section and gender and it looks like you want the values of the gender field to become column names. MySQL doesn't support these type of queries (cross-tab) so you have to manually do it. As long as you just have 4 genders use this: SELECT section, SUM(IF (gender="male", 1,0)) AS countmale, SUM(IF (gender="female", 1,0)) AS countfemale, SUM(IF (gender="gay", 1,0)) AS countgay, SUM(IF (gender="lesbian", 1,0)) AS countlesbian FROM mytable GROUP BY section; PHP: If you have more genders you need to paste in more of these: 'SUM(IF (gender="male", 1,0)) AS countmale'