By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,837 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,837 IT Pros & Developers. It's quick & easy.

Compare similar tables from separate MySQL servers

P: 1
I'm pulling in data from two servers over two SSH tunnels. The tables on each of the servers have the same fields, 8 in total. I need a way to see if an entry that is in the first server is also on the second server. Out of 8 of the fields, 5 will have to match to be considered a match (but I need to pull all 8 in order to use them in the display). I know I could use temp tables in mysql on the server running the php script, but I'd much rather do this all in php.

All said, I haven't found a way to compare such large amounts of data matching on multiple fields all within php. Any help would be greatly appreciated!
Jun 19 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 5,821
Heya, keleathi. Welcome to TSDN!

The tricky part (I'm assuming) is that you can't just go line-by-line because the rows might not match up. About the only thing you can do here is pick one server, load the entire table, then go through line-by-line and searching for the five required fields on the other server (remember to LIMIT 1 so that you don't keep looking after you find it!).

Even with a lot of rows, if your tables are properly indexed, it shouldn't take too long.

Erm... I presume that this is a one-time thing, right?

[EDIT: I suppose you could load both tables into PHP and search each row as an array, but why reinvent MySQL?]
Jun 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.