Results 1 to 2 of 2
  1. #1
    desgordon is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    5

    How to select the complement of two tables with composite primary keys

    I have two tables that have identical schema and one table has a subset of the data that exist in the other. I want to select the data from the first table (table1 say) that does not exist in the other (table 2) using a query of the form:


    Code:
        
    select * from table1 where Primary_key_field not in (select primary_key_field from table2) 
     My problem is that primary_key_field is not a single field but is a combination of three other fields.
    My question is whether in MS Access it is possible to do the query using a composite primary key field.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    See if this works:
    Code:
    Select * From table1 Where NOT EXISTS
    (Select table2.primary_key_field From table2 Where table1.primary_key_field = table2.primary_key_field);

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using composite keys but stuck badly in the design
    By hmushtaq in forum Database Design
    Replies: 2
    Last Post: 01-25-2011, 12:25 AM
  2. Replies: 2
    Last Post: 09-22-2010, 02:25 PM
  3. Using composite keys to enter data in a form
    By kymmyg in forum Database Design
    Replies: 2
    Last Post: 09-08-2010, 01:20 PM
  4. Combo boxes both primary keys to select record
    By Alexandre Cote in forum Forms
    Replies: 3
    Last Post: 08-10-2010, 07:11 AM
  5. Multiple primary keys
    By elektrisk in forum Access
    Replies: 5
    Last Post: 02-11-2010, 04:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums