Working with data from 2 databases
Hello
I am pulling data from two tables (seperate databases)into two different recordsets. It is likely that some of the data will be duplicated information. What I would like to be able to do is filter out the duplicates and just present the first record. This is simply a string that is going to be passed via a querystring to another page.
What is the best approach? I have not been able to merge both recordsets into one to be able to remove the duplicates. Or am I thinking about this the wrong way?
Here is what I have now - can get the data ok, just can't get rid of duplicates to pass on only the first instance of a string.
<%
Set Rs = Server.CreateObject("ADODB.Recordset")
Set Conn=server.createobject("adodb.connection")
Conn.Open "DSN=Names;",,3
Set Rs2 = Server.CreateObject("ADODB.Recordset")
Set Conn2=server.createobject("adodb.connection")
Conn2.Open "DSN=Movies;",,3
q= "SELECT * FROM table1 WHERE (First LIKE '%" & Request.Form("NameSearchtest") & "%' OR Last LIKE '%" & Request.Form("NameSearchtest") & "%') ORDER by first"
x="SELECT * FROM name WHERE Name LIKE '%" & Request.Form("NameSearchtest") & "%' ORDER BY Name"
rs.Open (q), "DSN=Names;",3
rs2.Open (x), "DSN=Movies;",3
%>
<%while NOT rs.EOF
first=rs("first")
last=rs("last")
%>
<TABLE CELLSPACING=0 CELLPADDING=4 WIDTH=550>
<TD Width = "300">
<b><a href="star.asp?<%=rs("First")&" " & rs("Last")%>"><%=rs("First")& " " & rs("Last")%></a></small></b>
</td>
</table>
<%
rs.MoveNext
wend
while NOT rs2.EOF
name=rs2("Name")
%>
<TABLE CELLSPACING=0 CELLPADDING=4 WIDTH=550>
<TD Width = "300">
<b><a href="star.asp?<%=rs2("Name")%>"><%=rs2("Name")%></a></small></b>
</td>
</table>
<%
rs2.MoveNext
wend
rs.Close
Set rs = nothing
conn.Close
Set conn = nothing
rs2.Close
Set rs2 = nothing
conn2.Close
Set conn2 = nothing
%>
|