|
 |
asp_databases thread: Search Engine help.
Message #1 by "Igor" <Accesssyst@a...> on Wed, 19 Sep 2001 20:00:59
|
|
I am working with a search right now and I am having problems with it.
I have 5 fields in DB that i need to search in(product_name,product_model
and so on...)When i enter two keywords as "Sony Mavica-109"("Sony" from
product_name and "Mavica-109" from product_model)my select statment return
no results. How can I fix
the search to allow more than one word in the keyword search separeted by
space?
Thanks in advance.
Gary S.
Message #2 by "J House" <jesse@s...> on Fri, 21 Sep 2001 17:14:53
|
|
maybe try storing your search criteria in an array
arrSearch = Split(Request("search), " ")
strSql = "SELECT * FROM Products WHERE "
for each oItem in arrSearch
strSql = strSql & "product_name = '" & oItem & "' " & _
"OR product_model = '" & oItem & "' "
next
if they typed in 'Sony Mavica-109' then your sql would look something like
SELECT * FROM Products WHERE product_name = 'Sony' OR product_model
= 'Sony' OR product_name = 'Mavica-109' OR product_model = 'Mavica-109'
you may want to use LIKE instead of =
I don't know if this will help you or not this kind of query seems like it
will return too many records in many cases.
> I am working with a search right now and I am having problems with it.
> I have 5 fields in DB that i need to search in
(product_name,product_model
> and so on...)When i enter two keywords as "Sony Mavica-109"("Sony" from
> product_name and "Mavica-109" from product_model)my select statment
return
> no results. How can I fix
> the search to allow more than one word in the keyword search separeted
by
> space?
>
> Thanks in advance.
> Gary S.
|
|
 |