Purpose: Query article keywords in the article table
Query format: Baidu Google Baidu is better or Google is better Baidu + Google (you can also query without entering conditions)
<!--#includefile="conn.asp"-->
<%
FunctionSearshSQL(Tname,Lname,Str)'Tname-Table nameLname-Column nameStr-Query character
IfTrim(Str)=""then
MySql="Select*From"&Tname
Else
Str=SqlEncode(Str)' preprocessing query string
ArrStr=split(Str,"")'The string is processed with spaces
Umax=Ubound(ArrStr)'After segmentation, the array is divided, determine the number of keywords divided into
IfUmax>0Then' processing of multiple spaces in the keyword "IfUmax>0Then" starts from the second dimension
Fori=1toUmax
StrTemp=ArrStr(i)
IfTrim(StrTemp)=""ThenStrTemp="/~~~~~/"'The elements divided into are empty and are replaced by special characters.
Sql=Sql&"Or"&Lname&"like'%"&StrTemp&"%'"
Next
EndIf
MySql="Select*From"&Tname&"where"&Lname&"like'%"&ArrStr(0)&"%'"&Sql
Do
j=InStr(1,MySql,"%/~~~~~/%",1)
Ifj=0Then
ExitDo
EndIf
MySql=Replace(MySql,"Or"&Lname&"like'%/~~~~~/%'","")