SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Finland
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Finding records not in a table

    Hi all,

    Long time, no post. Anyhoo, I've got a small mySQL problem. I'm cleaning up in the company's internal computer/employee db. I've got two tables, tblPerson and tblPersonComputerLink. tblPerson contains all info on an employee (ID, firstname, lastname, etc.) and tblPersonComputerLInk has two columns, one for personID and one for computerID, for linking a person to a computer.

    What I want to do is find the persons who aren't linked to a computer, ie. their ID wouldn't exist in the tblPersonComputerLink table. The best query I've vome up with so far is:

    Code:
    SELECT tblPerson.firstName, tblPerson.lastName, tblPersonComputerLink.personID
    FROM tblPerson INNER JOIN tblPersonComputerLink ON tblPerson.employmentNo = tblPersonComputerLink.personID 
    WHERE tblPerson.employmentNo NOT IN(tblPersonComputerLink.personID)
    This returns 0 rows, which isn't right, since I know there are people in the table who aren't linked to a computer.

    Any suggestions?

    Cheers,
    ~Jens

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Örebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Take a look at this post. That should give you an idea of how to do it.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Finland
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jättebra, tack!

    ~Jens


Bookmarks

Posting Permissions

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