In web development, I often encounter multiple keyword pairs of a single field query, I usually through a 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.
Program code:
The following are the referenced contents:
' Search for keywords
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