pilixonis Posted September 11, 2011 Share Posted September 11, 2011 Hi! I have two similarĀ tables on two different databases and i need to check if there are any entries on the table1, for example, that there aren't on the second table and print if there are i need to print them. Any suggestions? Thank you... Quote Link to comment https://forums.phpfreaks.com/topic/246898-compare-two-tables-from-two-databases/ Share on other sites More sharing options...
voip03 Posted September 11, 2011 Share Posted September 11, 2011 The UNION operator in MySQL can help you to compare data of two tables of two different databases http://www.tizag.com/sqlTutorial/sqlunion.php Quote Link to comment https://forums.phpfreaks.com/topic/246898-compare-two-tables-from-two-databases/#findComment-1267946 Share on other sites More sharing options...
marcelobm Posted September 11, 2011 Share Posted September 11, 2011 you can just use a left or right join with full reference to the tables like: SELECT * FROM db1.table1 LEFT JOIN db2.table2 ON db1.table1.id = db2.table2.id WHERE db2.table2.id != ''; This should give you the records of db1.table1 that aren't on db2.table2 Quote Link to comment https://forums.phpfreaks.com/topic/246898-compare-two-tables-from-two-databases/#findComment-1267947 Share on other sites More sharing options...
pilixonis Posted September 11, 2011 Author Share Posted September 11, 2011 Thank you marcelobm that was correct, i did it this way and it worked. Quote Link to comment https://forums.phpfreaks.com/topic/246898-compare-two-tables-from-two-databases/#findComment-1267952 Share on other sites More sharing options...
marcelobm Posted September 11, 2011 Share Posted September 11, 2011 glad i could help Quote Link to comment https://forums.phpfreaks.com/topic/246898-compare-two-tables-from-two-databases/#findComment-1267955 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.