SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Sep 2008
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Query - pretty simple

    Table 1
    ---
    uniqueID / employeeName
    1 / Dave
    2 / Steve
    3 / Robert

    Table 2
    ---
    job / employeeID
    "telephone Mr Smith" / 2
    "complete report abc" / 1

    Table 3
    ---
    notes / employeeID
    "various text entered here" / 2
    "hello, more notes" / 2


    For my sql query I need to check which employees (from table 1 and if any) DO appear in table 2, but then not in table 3. In this case this would be YES, employee 1.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Use an inner join on table 1 and 2, and a left join on table 1 and 3.

  3. #3
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    select uniqueID from tab1 inner join tab2 on tab1.uniqueID =tab2.employeeID
    where tab.uniqueID not in (select employeeID from tab3)


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
  •