Tracking differences between tables

  • Thread starter Thread starter DevilDog1978
  • Start date Start date
D

DevilDog1978

I have two tables [pcinventry unedited] and [pcinventrySQL] I want to compare
the differences in the fields model, fscm, nomen, and std_cal. Both tables
use ecn as a common unique field. I would like to be able to generate
individual reports highlighting the differences based on sub_cust (via a
dropdown if possible). Any clue on how to go about doing this?
 
To start withy you will want to think through and define exactly what you
want to see. I.E. exactly what would it show and under what conditions.

Then create a query which joins the two tables, PK to PK, and which
implements your answer(s) from the previous paragraph.

For example, If the Field1 in Table A doesn't match Field1 in Table B,show
/ list the contents of those two fields pllus the PK value.
 
to get you started:
SELECT A.* FROM A
WHERE NOT EXISTS (SELECT 'X' FROM TABLE B
WHERE B.F1 = A.F1 OR B.F2 = A.F2)
UNION ALL
SELECT B.* FROM B
WHERE NOT EXISTS (SELECT 'X' FROM TABLE A
WHERE B.F1 = A.F1 OR B.F2 = A.F2)

hth
Pieter
 
Back
Top