|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help with joins
I am having a nightmare with this query
SELECT Employee.ssn FROM Employee INNER JOIN Manages on Employee.ssn = Manages.ssn WHERE (SELECT COUNT(e.ssn) as SSN, d.dno FROM Employee e INNER JOIN Manages m ON e.ssn = m.ssn INNER JOIN Works w ON m.dno = w.dno INNER JOIN Department d ON w.dno = d.dno GROUP BY e.ssn, d.dno HAVING COUNT(e.ssn) > 5); The bold bit is the original query where it finds all departments where these is more than 5 employees. I need to find the ssn of the employee who manages that department. In MySQL it points to the nested select whereas in Oracle it says Too many values Here is the table structure I have been struggling to create this query all dat and am ready to give up I want to select all employee_ids who manages a department with more than 5 employees Employee table ------------------- ssn (primary key) Manages table ------------------ ssn(foreign key) dno(foreign key) Works_in table ------------------ ssn (foreign key) dno(foreign key) Department table ---------------------- dno(primary key) |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Need help with joins |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|