ASP处理多关键词查询实例代码
程序员文章站
2022-04-14 19:44:46
程序代码: 复制代码 代码如下: '关键字的搜索 str="select * from tablename where id>4" if srhkey<>...
程序代码:
'关键字的搜索
str="select * from tablename where id>4"
if srhkey<>"" then
keyarr=split(srhkey," ")
j=ubound(keyarr)
t=0
dim keystrarr()
for i=0 to j
if keyarr(i)<>"" then
redim preserve keystrarr(t)
strfilter="(empzw like '%"&keyarr(i)&"%' or empdep like '%"&keyarr(i)&"%' or empgz like '%"
strfilter=strfilter&keyarr(i)&"%' or empwy1 like '%"&keyarr(i)&"%' or empwy2 like '%"&keyarr(i)
strfilter=strfilter&"%' or empyq like '%"&keyarr(i)&"%' or com_name like '%"&keyarr(i)&"%')"
keystrarr(t)=strfilter
t=t+1
end if
next
keystr=join(keystrarr," and ")
str=str&" and "&keystr
end if
复制代码 代码如下:
'关键字的搜索
str="select * from tablename where id>4"
if srhkey<>"" then
keyarr=split(srhkey," ")
j=ubound(keyarr)
t=0
dim keystrarr()
for i=0 to j
if keyarr(i)<>"" then
redim preserve keystrarr(t)
strfilter="(empzw like '%"&keyarr(i)&"%' or empdep like '%"&keyarr(i)&"%' or empgz like '%"
strfilter=strfilter&keyarr(i)&"%' or empwy1 like '%"&keyarr(i)&"%' or empwy2 like '%"&keyarr(i)
strfilter=strfilter&"%' or empyq like '%"&keyarr(i)&"%' or com_name like '%"&keyarr(i)&"%')"
keystrarr(t)=strfilter
t=t+1
end if
next
keystr=join(keystrarr," and ")
str=str&" and "&keystr
end if