Results 1 to 5 of 5
  1. #1
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142

    Isolating Records from 2 Tables that do not Match


    I have 2 large tables (approx 50k records each). They mostly match on my key, but one table has some record keys that the other does not.

    What I want to do is match them on their keys (easy enough), but instead of getting a list of all the matches, I want a list of the mismatches (extra records) on that one table. Is there a reasonably easy query technique for doing that?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    Make an OUTER join:
    make the normal query with the join to get the matches (inner join)
    bring down the key from both tables into the grid
    dbl-click the join line
    set to: show ALL records from table1, Some recs from table2
    under criteria for key.table2, set NULL

    this will show all recs in table1, and the missing in table2

    then reverse the join (and criteria) to see all recs in table2 and missing in table1

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,747
    Access provides a Query Wizard. One of the options is Unmatched Query.
    It provides a dialog to assist you to create the query and run it.

    Click image for larger version. 

Name:	SampleUnmatchedQuery.PNG 
Views:	8 
Size:	17.0 KB 
ID:	37289


    General format of unmatched query as Ranman suggested.
    Code:
    'in this example, I'm looking for Animals that have not been captured.
    SELECT Animal.AName
    FROM Animal
    LEFT JOIN AnimalCapture ON Animal.[AnimalId] = AnimalCapture.[AnimalId]
    WHERE (((AnimalCapture.AnimalId) IS NULL));
    Good luck.

  4. #4
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    Thank you.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,747
    You are welcome. There are other options in the Query Wizard also that can be useful in certain cases.

    Good luck.

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

Similar Threads

  1. Editing report format and isolating records
    By AKawser in forum Reports
    Replies: 2
    Last Post: 07-29-2016, 03:26 AM
  2. Relating tables so records match
    By Bkper087 in forum Access
    Replies: 3
    Last Post: 05-08-2014, 12:14 PM
  3. Replies: 11
    Last Post: 02-06-2014, 10:05 PM
  4. Replies: 5
    Last Post: 04-26-2012, 05:25 PM
  5. Replies: 2
    Last Post: 12-18-2011, 02:32 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