SOLVED: How to easily compare two MySQL tables to find data differences?

Today I performed some complex database merging and the data as well as the table structures had to be compared properly before the production launch.

Following little MySQL query helped me a lot to get the job done.

Here the query will compare ID columns of two tables and return all found in Table_A which it cannot see in Table_B. You can modify the query for different comparisons and enjoy :).

SELECT * FROM Table_1
WHERE Table_1.ID
NOT IN (
SELECT Table_2.ID
FROM Table_2
WHERE Table_1.ID=Table_2.id
)

Hope this will help to your situation as well!

Comments

You are welcome to share your ideas with us in the comments!

Archive

Contact Form

Send