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:
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=" & rs("IdCode") & " 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
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.
答案 0 :(得分:0)
我建议不要在第一个SELECT中使用*。你不需要那里的所有字段。而只使用IdCode。