title: How to speed up a cross search on different MySql Servers?
body: <p>I have the following problem. A Classic ASP application needs to access 2 different DB (tables) on two different mysql servers (different remote locations, accessed via IP over the net). The goal is to select all records matching a couple of conditions from the first DB table on the first server (making a recordset), and then, among these records, just select those whose IdCode match with the IdCode of (at least) one record from the DB table on the second server, together with a third condition to match in this second table.
  I have a simple (stupid) way to do this which is:</p>
  
  <pre><code>strSQL = "SELECT * FROM Serv1_Table1 WHERE condition1 AND condition2;"
  SET rs = conn1.Execute(strSQL)
  DO WHILE NOT rs.EOF
    strSQL = "SELECT IdCode FROM Serv2_Table2 WHERE IdCode=" &amp; rs("IdCode") &amp; " AND condition3 LIMIT 1;"
    SET rs2 = conn2.Execute (strSQL)
    IF NOT rs2.EOF THEN
       call operation_to_do (using rs recordset)
    END IF
    rs.movenext
  LOOP
  </code></pre>
  
  <p>This works fine, but is pretty slow (working over a few thousands records in each of the two servers). What I'd like to find is a more efficient and speedy way to do the same in this situation. Any ideia or suggestion ??
  Thanks a lot.</p>