Welcome to WebmasterWorld Guest from 18.104.22.168
First I insert each user table into a multidimensional array and compare each row of TABLE A with all the rows of TABLE B through a FOR statement.
So it loops about 7000 x 2000 = 14000000 times. A bit too much if you ask me and it always times out, so I was wondering if any body had any ideas on any more effecient ways to do it.
An idea I had was a big table join but theyre in different DB's so that wouldnt work. Anyone? :)
However, if you can't, why not simply copy the one table into the other database, do your table join procedure and then put the new table back whereever you need to?
Anyway, make a new table C with the layout you want. Create a primary key or a unique index on the fields you what to match.
INSERT IGNORE INTO C SELECT fields_from_A FROM A;
INSERT IGNORE INTO C SELECT fields_from_B FROM B;
This will give precedence to records from A.
Duplicates will be removed due to the unique key and you won't get errors for key-clashes because of the IGNORE keyword.
This should get you what you want.