Multiple keywords search

Results 1 to 2 of 2

Thread: Multiple keywords search

  1. #1
    Michael V Guest

    Default Multiple keywords search

    I have a search set up and it works fine... Except when you search with more than one keyword. When you search with more than one keyword no results are found. Here is the statement I am using.<BR><BR>&#060;------ CODE -------&#062;<BR>TempSearch = Request("Keywords")<BR>SQLText = "select * from TechTips where Tip like &#039%" & TempSearch & "%&#039 OR Title like &#039%" & TempSearch & "%&#039"<BR>&#060;------END CODE ------&#062;<BR><BR>Is there any way to get more than one keyword to work?<BR><BR>Many thanks,<BR>Michael

  2. #2
    Join Date
    Dec 1969

    Default RE: Multiple keywords search

    Something like this?<BR><BR>&#060;%<BR>words = Split( Request("Keywords") )<BR>tipCheck = ""<BR>titleCheck = ""<BR>For wnum = 0 To UBound(words)<BR>&nbsp; &nbsp; If wnum &#060;&#062; 0 Then<BR>&nbsp; &nbsp; &nbsp; &nbsp; tipCheck = tipCheck & " AND "<BR>&nbsp; &nbsp; &nbsp; &nbsp; titleCheck = titleCheck & " AND "<BR>&nbsp; &nbsp; End If<BR>&nbsp; &nbsp; tipCheck = tipCheck & "Tip LIKE &#039%" & words(wnum) & "%&#039"<BR>&nbsp; &nbsp; titleCheck = titleCheck & "Tip LIKE &#039%" & words(wnum) & "%&#039"<BR>Next<BR><BR>SQL = "SELECT * FROM TechTips WHERE (" & tipCheck & ") OR (" & titleCheck & ")"<BR><BR>...<BR><BR>%&#062;<BR><BR>Does that make sense? Untested, but it looks right to me.<BR><BR>This assumes the user wants to find ALL words in the same place. Just replace the AND with OR if the user wants to find ANY words. (Obviously, you could let the user make a checkbox or radio button select to specify ALL or ANY.)<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts