How to compare differences between MySQL tables

If I have two identical mysql tables (same name, same fields etc) how can I compare if the data is the same from each row?

I don’t quite get how you can have two tables with the same name…

Ok, well not same name, but same structure etc…

Do you mind me asking why you’re going to have two tables with the same structure? Sorry, not trying to be difficult, but this usually indicates a problem with database design that when rectified may well sort out the problem you’re trying to solve here.

I am creating an auto upgrade feature for an application I have and would just like to see which tables I have updated since the last release.

To find different values in corresponding fields:

SELECT a.PrimaryKey
FROM TableA a
INNER JOIN TableB b ON a.PrimaryKey = b.PrimaryKey
WHERE a.FieldA <> b.FieldA
OR a.FieldB <> b.FieldB
etc…

To find records in TableA that have no match in TableB:

SELECT a.PrimaryKey
FROM TableA a
LEFT JOIN TableB b ON a.PrimaryKey = b.PrimaryKey
WHERE b.PrimaryKey IS NULL

Great! Just a quick question; what does this part of the query do?

WHERE a.FieldA <> b.FieldA
OR a.FieldB <> b.FieldB