我的源代码:[local]1[/local]
数据库lunatic.mdb中的2个关联表有一个相同的字段“Number”,如下:
BigClass: [local]2[/local]
SmallClass:[local]3[/local]
提交关键字页面index.asp的代码:
程序代码:
<html> <head> <title>.............</title> </head> <body> <form action="search.asp" method="post" name="search" target="_blank"> <p>表BigClass的Big_Title字段 <input name="Big_Title" type="text" value="" size="20"> </p> <p>表SmallClass的Small_Title字段 <input name="Small_Title" type="text" value="" size="20"></p> <p><input type="submit" name="Submit" value="搜索"></p> </FORM> </body> </html>
查询结果页面search.asp的代码:
程序代码:
<% strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.mappath("database/lunatic.mdb")+";Persist Security Info=False" set conn = Server.CreateObject("ADODB.Connection") conn.open strConn %> <html xmlns="http://www.> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <body> <% sql="select * from BigClass where Big_Title like '%"&request("Big_Title")&"%' " set rs=Server.CreateObject("ADODB.RecordSet") rs.open sql,conn,1,1 if rs.bof and rs.eof then response.Write("对不起,没有找到您需要的记录!") else do while not rs.eof %> <table align="center" width="400" border="0" cellpadding="3" cellspacing="0"> <tr style="color:#FF0000"> <td width="200"><%=rs("Number")%></td> <td width="200"><%=rs("Big_Title")%></td> </tr> <% sqlt="select * from SmallClass where Number = '"&rs("Number")&"' and Small_Title like '%"&request("Small_Title")&"%' " set rst=Server.CreateObject("ADODB.RecordSet") rst.open sqlt,conn,1,1 if rst.bof and rst.eof then response.Write("<tr><td style='font-size:13px; color:#FF0000'>小类下没有记录!</td></tr>") response.Write("<tr><td> </td></tr>") else do while not rst.eof %> <tr> <td><%=rst("Small_Title")%></td> <td><%=rst("Small_Name")%></td> </tr> <% rst.movenext loop end if rst.close Set rst = Nothing %> </table> <hr> <% rs.movenext loop end if rs.close Set rs = Nothing conn.close set conn=nothing %> </body> </html>
我在index.asp页面提交一个关键字“手持终端”进行查询:
[local]4[/local]
查询出来的结果:
[local]5[/local]
请问大家,我如何让“XS004 福建移动公司”这条记录不显示出来,只读取前面的XS001、XS002、XS003这3条记录的“手持终端”的信息。也就是读取的结果如下图:
[local]6[/local]
请问该怎么实现,谢谢!