搜索数据库

当你在查询一个你在寻找的实际的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>

简单生活,希望对大家有用!要觉得本文有价值请分享给您的朋友,生活就是人来人往,分享越多!收获越多!作者:天天ASP家园

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值