Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2002
    Posts
    43

    Unanswered: Query Help needed

    I have two tables

    Table1
    ID
    Name

    table2
    Id
    code

    I need a query that will give me the ID's in table 2 that are not in table 1. Yes I know this should be handled by key constraints, but it is not so I need to find the keys in table 2 that do not have a match in table 1. If I do a join I only get the records where the id's are equal.

  2. #2
    Join Date
    Dec 2002
    Posts
    134

    Re: Query Help needed

    1. select id from table2 where id not in (select id from table1 )
    2. select id from table2 where not exists (select * from table1 where table1.id = table2.id)
    3. select id from table2 except select id from table1
    4. select distinct table2.id from table2 left outer join table1 on table1.id = table2.id where table1.id is null

  3. #3
    Join Date
    Feb 2002
    Posts
    43
    Thank you number 4 was the correct answer for my problem. My software will not allow subqueries so that one worked just fine. Thanks again.

Posting Permissions

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