Two table data compare

I have two table that I need to compare for data:
Table 1                    Table 2
EmpId       EmpStatus      EmpID   EmpStatus

I am trying to compare table 1 and table 2 and check to see if  
Table 1 EmpStatus is different from Table 2 EmpStatus

Most of the records match, but some don't.

Table 1                                Table 2
EmpID       EmpStatus           EmpID      EmpStatus
1123            A            1123            A
1124            C            1124            C
1125            C            1125            C        
1126            A            1126            C   <<---- this is the record that I want displayed


I have imported Table 1 and Table 2 into an MS Access database to do the data compare work..

Thanks in advance.
donnie91910Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
Please try this-

You can change JOIN to any of - LEFT OUTER JOIN / RIGHT OUTER JOIN based on your need.

--


SELECT t1.EmpID , t2.EmpID, t1.EmpStatus , t2.EmpStatus 
, IIF(t1.EmpStatus = t2.EmpStatus , 'MATCHED' , 'NOT MATCHED') as MatchingColumn  
FROM Table2 as t2 INNER JOIN Table1 as t1
ON t1.EmpID = t2.EmpID  


--

Open in new window


OUTPUT

EmpID       EmpID       EmpStatus EmpStatus MatchingColumn
----------- ----------- --------- --------- --------------
1123        1123        A         A         MATCHED
1124        1124        C         C         MATCHED
1125        1125        C         C         MATCHED
1126        1126        A         C         NOT MATCHED

Open in new window

0
Pawan KumarDatabase ExpertCommented:
In the last comment I have created a new column called "Matching", this column will tell us which rows are matching and which are not matching.

or we can use old syntax..but I prefer the new syntax only.

SELECT t1.EmpID , t2.EmpID, t1.EmpStatus , t2.EmpStatus 
, IIF(t1.EmpStatus = t2.EmpStatus , 'MATCHED' , 'NOT MATCHED') as MatchingColumn  
FROM Table2 as t2 , Table1 as t1
WHERE t1.EmpID = t2.EmpID  

Open in new window


OUTPUT

EmpID       EmpID       EmpStatus EmpStatus MatchingColumn
----------- ----------- --------- --------- --------------
1123        1123        A         A         MATCHED
1124        1124        C         C         MATCHED
1125        1125        C         C         MATCHED
1126        1126        A         C         NOT MATCHED

Open in new window

0
als315Commented:
May you have missing IDs in one of tables?
0
Fabrice LambertFabrice LambertCommented:
Or simplyer version:
SELECT   Table1.EmpID,    Table1.EmpStatus,
         Table2.EmpID,    Table2.EmpStatus
FROM     Table1 INNER JOIN Table2
             ON Table1.EmpID = Table2.EmpID
WHERE    Table1.EmpStatus <> [Table2].[EmpStatus];

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fabrice LambertFabrice LambertCommented:
solutions provided
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.