Comparing Data in TABLES

  • Thread starter Thread starter Gerrym
  • Start date Start date
G

Gerrym

I have two Tables, A and B. Both have the same
structures, keys etc. Both are downloads from another
Table at different times. I would like to be able to
compare the data in these two tables to highlight the
different records. I need to compare the complete record
not just one field. Can anyone advise how to do this,
please.

Gerry
 
Try this

Select T1.Field1,T1.Field2..T1.FieldN from Table1 T1, Table2 T2
where T1.Field1=T2.Field1 and T1.Field2=T2.Field2 and .... and
T1.FieldN=T2.FieldN

Madhivanan
 
Of course, that won't highlight the differences as Gerry asked for: it'll
only show the rows that are the same.
 
You can join them on their keys, and compare the non-key fields.

Something like:

SELECT T1.ID, T1.F1, T1.F2, T1.F3, T1.F4,
T2.F1, T2.F2, T2.F3, T2.F4
FROM T1 INNER JOIN T2
ON T1.ID = T2.ID
WHERE T1.F1 <> T2.F1
OR T1.F2 <> T2.F2
OR T1.F3 <> T2.F3
OR T1.F4 <> T2.F4
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top