Results 1 to 2 of 2

Thread: Many-To-Many

  1. #1
    Join Date
    Feb 2004
    Posts
    3

    Unanswered: Many-To-Many

    I have tried this post in the PostgreSQL, but it is probably more specific to this forum. Sorry for any duplicates.

    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.

    A more graphical representation of the tables:
    tasks
    -taskid
    -task_name
    -due_date
    -assignment_date

    employees
    -employeeid
    -first_name
    -last_name

    participants
    -participantid
    -taskid
    -employeeid

    Thanks for any input.

  2. #2
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Select *
    from tableA
    where id NOT IN
    (Select id from tableB)
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Posting Permissions

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