Multi-keyword Search instance ASP code

Source: Internet
Author: User

In the use of ASP for Web page development, often encounter multiple keyword query search function, I usually through dynamic array to achieve. Of course, a number of keywords are generally used in space or, separated, I this several assumptions with a number of keywords separated by space, the keyword string for keystr, specific code for.

Here's the code:
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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.