Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    3

    Unanswered: Many-To-Many Query

    I have two tables one is a tasks table and the other an employees table. A third table I have is called participants. This third table holds the IDs of tasks and the IDs of employees assigned to complete those tasks. My problem is figuring out how to select employee IDs and names from the employees table that are not associated with a specific taskid in the participants table.
    My first attampt was:
    SELECT Employees.employeeid,Employees.username FROM Employees,Participants WHERE Participants.taskid=# AND Employees.employeeid!=Participants.employeeid.

    #=any valid integer id in the taskid field of the Participants table.

    This attempt just gave me everyone in the Employees table.

    Thanks for any input.

  2. #2
    Join Date
    Feb 2004
    Location
    Siggenthal, Switzerland
    Posts
    19
    Select e.employeeid, e.username
    from employees e where
    e.employeeid not in
    (select p.employeeid from participants p)

    Walter

  3. #3
    Join Date
    Feb 2004
    Posts
    3

    Thank You!

    I never even thought about subselects. I really appreciate your quick and accurate reply!

    -Sionix

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •