Hi!
For this problem, I’m using three tables:
Employees (id, lastName, firstName, etc.)
Groups (id, group, description)
GroupsLink (id, empID, groupID)
I need to be able to display all employees of a particular group based on groupID. This works great:
$sql = "SELECT Employees.lastName , Employees.firstName, Employees.id
FROM Employees , GroupsLink
WHERE (
( GroupsLink.groupID = $id ) AND (GroupsLink.empID = Employees.id )
)";
But next I want to display all the employees that are NOT in that group. I could probably do this with php by setting two arrays and comparing, but it sure seems like there must be an easier/more efficient way to do this with a query. I’ve tried different things after Google searching, but I either end up with nothing or multiple duplicates.
Anyone got ideas or suggestions?
(MySQL Version 5.0.45; PHP Version 5.2.17)