建站代码网

热门标签

搜索数据库

当你在查询一个你在寻找的实际的match函数(=)小于(<),大于(>),小于或等于(<=),大于或等于(=>),或者不等于(< >)的理论的数据库的时候。这会给你一个相当多的你能显示的数据的方式,但是用这个运算符部分的match函数是不行的。为了能更好地完成一个部分match函数,像运算符一定是要用到的,那是要看你是怎么样完整地搭建这个函数的。数据库这个例子包括在黑板上写出的多数的Titles,AirDates和What Bart Simpson 在The Simpson's (TM)。如果我们要搜索所有的标题,airdates,段数和黑板上的字符,那就要写出像这样的以"will"开始的字符。

u_search="will" sql = "select * from shows where blackboard " like '"& u_search & "%%'" If we were to search the db for all show titles, airdates, episode numbers and blackboards where a word in the blackboard writing ends with "will" the sql would look like this u_search="will" sql = "select * from shows where blackboard " like '%%"& u_search & "'" If we were to search the db for all show titles, airdates, episode numbers and blackboards where a word in the blackboard writing contains "will" the sql would look like this u_search="will" sql = "select * from shows where blackboard " like '%%"& u_search & "%%'" <% u_search=request.form("u_search") u_where=request.form("u_where") if u_search = "" or u_where= "" then response.redirect "sim_input.asp" end if accessdb="simpsons" cn="DRIVER={Microsoft Access Driver (*.mdb)};" cn=cn & "DBQ=" & server.mappath(accessdb) Set rs = Server.CreateObject("ADODB.Recordset") sql = "select * from shows where " & u_where &" like '%%"& u_search & "%%'" rs.Open sql, cn If rs.eof then search="nothing" end if %> <title><%= sql %></title> <body bgcolor="#FFFFFF"> <font face="arial" size="2"> <p> <%= sql %> </p> </font> <% if search <> "nothing" then %> <div align="left"> <table border="0" cellpadding="0" cellspacing="0" width="690"> <tr> <td width="220" valign="top" align="left"><font face="Arial" size="1"><b>Title</b></font></td> <td width="50" valign="top" align="left"><font face="Arial" size="1"><b>Episode</b></font></td> <td width="60" valign="top" align="left"><font face="Arial" size="1"><b>AirDate</b></font></td> <td width="360" valign="top" align="left"><font face="Arial" size="1"><b>Black Board</b></font></td> </tr> <% end if %> <% On Error Resume Next rs.MoveFirst do while Not rs.eof %> <tr> <td width="220" valign="top" align="left"> <font face="Arial" size="1"> <%= rs("title") %></font></td> <td width="50" valign="top" align="left"> <font face="Arial" size="1"> <%= rs("episode") %></font></td> <td width="60" valign="top" align="left"> <font face="Arial" size="1"> <%= rs("airdate") %></font></td> <td width="360" valign="top" align="left"> <font face="Arial" size="1"> <%= rs("blackboard") %></font></td> </tr> <% rs.MoveNext loop%> <% if search = "nothing" then %> <div align="left"> <table border="0" cellpadding="0" cellspacing="0" width="640"> <tr> <td valign="top" align="left"> <font face="Arial" size="2"> No Search Results Matched <%= u_search %></font></td> </tr> <% end if %> </table> </div>

热门信息

X