Solved

In Access 2010 How can I find records in one table that have no exact match in another table?

Posted on 2015-02-18
6
129 Views
Last Modified: 2015-02-18
I need to find records that do not match by multiple fields.  What's a good strategy, or is there some generic SQL statements that might give me a clue?
0
Comment
Question by:Jay Williams
6 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 40617196
SELECT a.*
FROM a LEFT JOIN b ON
b.primarykey = a.primarykey
WHERE a.primarykey is not null and b.primarykey is null

Will give you all records in a that don't have a match in b.

Kelvin
0
 

Author Comment

by:Jay Williams
ID: 40617204
Thanks, Kevin.  I'll give it a whirl.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40617215
if you want to test for multiple fields

SELECT Table1.F1, Table1.F2, Table1.F3, Table1.F4, Table2.F1, Table2.F2, Table2.F3, Table2.F4
FROM Table1 LEFT JOIN Table2 ON (Table1.F4 = Table2.F4) AND (Table1.F3 = Table2.F3) AND (Table1.F2 = Table2.F2) AND (Table1.F1 = Table2.F1)
WHERE (((Table2.F1) Is Null) AND ((Table2.F2) Is Null) AND ((Table2.F3) Is Null) AND ((Table2.F4) Is Null));
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40617230
One of the query wizard options is a "Find Unmatched" query, which will walk you through the steps of identifying which field(s) you want to match on, and will allow you to select other fields from the table as well.
0
 

Author Comment

by:Jay Williams
ID: 40617288
Thanks again, Rey.  That's what I have in mind.  I'll let you know. :-)
0
 

Author Closing Comment

by:Jay Williams
ID: 40617325
This is pure gold--and so are you.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now