用途:文章表内文章关键字查询
查询格式: 百度 google 百度好还是google好 百度+google (也可不输入条件全部查询)
<!--#include file="conn.asp"-->
<%
Function SearshSQL(Tname,Lname,Str) 'Tname-表名 Lname-列名 Str-查询的字符
If Trim(Str)="" then
MySql="Select * From "&Tname
Else
Str=SqlEncode(Str) '预处理查询字符串
ArrStr=split(Str," ") '用空格分割处理后字符串
Umax=Ubound(ArrStr) '分割后数组上维,确定分割成关键词的个数
If Umax>0 Then '关键词中多个空格的处理,从第2维开始处理
For i=1 to Umax
StrTemp=ArrStr(i)
If Trim(StrTemp)="" Then StrTemp="/~~~~~/" '分割成的元素为空用特殊字符代替
Sql=Sql &" Or "& Lname &" like '%"& StrTemp &"%'"
Next
End If
MySql="Select * From "& Tname &" where "& Lname &" like '%"&ArrStr(0)&"%'"&Sql
Do
j=InStr(1,MySql, "%/~~~~~/%",1)
If j=0 Then
Exit Do
End If
MySql=Replace(MySql," Or "&Lname&" like '%/~~~~~/%'","")
Loop
End IF
SearshSQL=MySql
end function
Function SqlEncode(Str) '格式化字符串
str=replace(str," "," ") '先把左右的全角空格替换成半角空格
str=trim(str)
str=replace(str,"["," ")
str=replace(str,"';"," ")
str=replace(str,"'"," ")
str=replace(str,"_"," ")
str=replace(str,"%"," ")
str=replace(str,"+"," ")
str=replace(str," "," ")
sqlencode=str
end function
%>
<%
sql=SearshSQL("article","coments","萝卜+白菜 狗熊") +"order by..(排序)"
Set rs=Server.Createobject("ADODB.RECORDSET")
rs.Open sql,conn,1,1
if not rs.eof then
下面的自己写
查询格式: 百度 google 百度好还是google好 百度+google (也可不输入条件全部查询)
<!--#include file="conn.asp"-->
<%
Function SearshSQL(Tname,Lname,Str) 'Tname-表名 Lname-列名 Str-查询的字符
If Trim(Str)="" then
MySql="Select * From "&Tname
Else
Str=SqlEncode(Str) '预处理查询字符串
ArrStr=split(Str," ") '用空格分割处理后字符串
Umax=Ubound(ArrStr) '分割后数组上维,确定分割成关键词的个数
If Umax>0 Then '关键词中多个空格的处理,从第2维开始处理
For i=1 to Umax
StrTemp=ArrStr(i)
If Trim(StrTemp)="" Then StrTemp="/~~~~~/" '分割成的元素为空用特殊字符代替
Sql=Sql &" Or "& Lname &" like '%"& StrTemp &"%'"
Next
End If
MySql="Select * From "& Tname &" where "& Lname &" like '%"&ArrStr(0)&"%'"&Sql
Do
j=InStr(1,MySql, "%/~~~~~/%",1)
If j=0 Then
Exit Do
End If
MySql=Replace(MySql," Or "&Lname&" like '%/~~~~~/%'","")
Loop
End IF
SearshSQL=MySql
end function
Function SqlEncode(Str) '格式化字符串
str=replace(str," "," ") '先把左右的全角空格替换成半角空格
str=trim(str)
str=replace(str,"["," ")
str=replace(str,"';"," ")
str=replace(str,"'"," ")
str=replace(str,"_"," ")
str=replace(str,"%"," ")
str=replace(str,"+"," ")
str=replace(str," "," ")
sqlencode=str
end function
%>
<%
sql=SearshSQL("article","coments","萝卜+白菜 狗熊") +"order by..(排序)"
Set rs=Server.Createobject("ADODB.RECORDSET")
rs.Open sql,conn,1,1
if not rs.eof then
下面的自己写
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“比较不错的asp单表单字段多条件查询”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。