This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a java program which connects to a MySQL server and performs simple tasks like adding, removing and updating entries. I am also creating some reports but i am stuck on 1 select query which isnt giving me the desired output.
The tables needed for this query are:
Staff: StaffID, Staff_Name
Modules: ModuleID, Module_Name, Credits
Teaches: StaffID, ModuleID
I am trying to select the staff members who teach more than one module, so far i have this
SELECT Staff.Staff_Name FROM Staff INNER JOIN (SELECT StaffID FROM Teaches GROUP BY StaffID HAVING COUNT(DISTINCT ModuleID) > 1)Teaches ON Teaches.StaffID = Teaches.StaffID
But this is giving me output of
Where staff 1 teaches two modules, staff 2 teaches three modules and Staff 3 only teaches one module