Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: SQL search for words with spaces in them....


Message #1 by "Marc Bartolome" <machba@y...> on Tue, 4 Mar 2003 06:57:07
Hello,

my site has a search form which allows users to search an Access DB for 
persons by last name. The search uses VBscript. One of the records in the 
DB has a last name of "Mc Griff".  The problem I am having is the record 
will only come up if they enter the name with the space between Mc and 
Griff.  If you enter "McGriff" the record does not get returned.  Any 
recommendations on how to solve this problem?  Thanks in advance...

Message #2 by "Josh Katsaros" <katsarosj@y...> on Tue, 4 Mar 2003 15:21:17
One way to do this would be to do a search on both "Mc Griff" 
and "McGriff".  For example, if the user enters "McGriff", append to your 
query an "OR" clause to search for either field.  Something like (using 
ASP??):

If Left(Request.Form("SearchField"), 2) = "Mc" Then
  'Code to search for McGriff' OR
  'Code to search for Mc Griff'
End If

You could also change this code to search anything after 'Mc', not 
just 'Griff', using the "InStr", "Mid", and "Right" functions.  Hope this 
helps.

JK

> Hello,

> my site has a search form which allows users to search an Access DB for 
p> ersons by last name. The search uses VBscript. One of the records in 
the 
D> B has a last name of "Mc Griff".  The problem I am having is the record 
w> ill only come up if they enter the name with the space between Mc and 
G> riff.  If you enter "McGriff" the record does not get returned.  Any 
r> ecommendations on how to solve this problem?  Thanks in advance...


  Return to Index