Solved

Compare 3 fields in 2 tables and give differences

Posted on 2011-09-21
3
294 Views
Last Modified: 2012-05-12
access 2003
2 tables

Table1
Table2

3 fields in each table  same field names
fld1 PrimaryKey Dups-ok
fld2 PrimaryKey Dups-ok
fld3 PrimaryKey Dups-ok

What I need:
I need to compare table2 against table1 and tell me what  data exists in table1 that is not table2 ?


Thanks
fordraiders


0
Comment
Question by:fordraiders
3 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 36574517
Try:

Select T1.fld1, T1.fld2, T1.fld3
FORM Table1 as T1
LEFT JOIN Table2 as T2
ON T1.fld1 = T2.fld1
and T1.fld2 = T2.fld2
AND t1.fld3 = t2fld3
WHERE T2.fld1 IS NULL
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 36574566


Select A.* From
(
SELECT Table1.fld1, Table1.fld2, Table1.fld3,"Table1" as SourceTable
FROM Table1 LEFT JOIN Table2 ON (Table1.fld3 = Table2.fld3) AND (Table1.fld2 = Table2.fld2) AND (Table1.fld1 = Table2.fld1)
WHERE (((Table2.fld1) Is Null) AND ((Table2.fld2) Is Null) AND ((Table2.fld3) Is Null))

Union All
SELECT Table2.fld1, Table2.fld2, Table2.fld3, "table2"
FROM Table2 LEFT JOIN Table1 ON (Table2.fld3 = Table1.fld3) AND (Table2.fld2 = Table1.fld2) AND (Table2.fld1 = Table1.fld1)
WHERE (((Table1.fld1) Is Null) AND ((Table1.fld2) Is Null) AND ((Table1.fld3) Is Null))
) As A
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 36577279
Thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

12 Experts available now in Live!

Get 1:1 Help Now