SELECT pnumber, pname, COUNT(*)
FROM project
INNER JOIN works_on ON pno=pnumber
INNER JOIN department ON dnumber=dnum
GROUP BY pnumber
Right now, mysql will return the project number and name, along with the number of employees who are working on it. What I want to do is that mysql only count employees from department 5. In other words there are people from different departments working on projects, but I want only the ones from department 5 to be counted and not all.
WHEREclauses are for?WHEREclause. It would help if you showed the schema. Why do projects have department numbers? People are in departments, projects aren't.