-
Using Group By in a Query containing Inner Join
Dear expert
How can I get this query work in MYSQL 5.1? I have tried so many alternative syntaxes but non of them work.
I would like to get the name of the employees with more than 1 project assigned to them.
Here are the two tables:
employee (id, firstName, lastName, hiringDate, departmentID)
employee_project(employeeID, projectID)
Select e.e_id, e.e_fname, count(ep.empl_id) AS projectCount
From empl_pro ep inner join employee e
On e.e_id = ep.emp_id
Where count(ep.emp_id) > 1
Group by e.e_id, e.e_fname
I have tried so many other way of writing the query and non of them work in MYSQL 5.1 - INSERT INTO ... SELECT...doesn't work either.
I either get syntax error or error regarding 'invalid use of group'
BTW, the query works without the 'where' clause.. but I need to get the name of those employees with more than 1 project.
-
Looks like an old message, but wouldn't:
HAVING projectCount > 1
after the GROUP BY work?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|