You could split on a space or comma and loop over that list like so:

WHERE 1=1
AND (
<cfloop index="term" list="#FORM.search#" delimiters=" ">
        <cfif Len(term) GT 2>
                description LIKE '%#term#%' OR
        </cfif>
</cfloop>
)

<!----------------//------
andy matthews
web developer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->

-----Original Message-----
From: Greg Edmonds [mailto:[EMAIL PROTECTED]
Sent: Friday, February 10, 2006 8:18 AM
To: CF-Talk
Subject: Searching a database


Hello,

I was hoping someone could give me some advice or recommendations on how
they create search forms.  Currently I have a very basic system, that works
ok, but certainly could be better.

I run the following query against what the user types in the search box:

SELECT * FROM table
WHERE field LIKE '%#form.variable#%'

This seems to do ok, but has several limitations. In our database, we search
the description field of a part number.  Here is a specific example of
someone searching the word "superdish":

Searches for: super - returns everything.
Searches for: super dish - returns nothing.
Searches for: superdish - returns everything.

If we change the description of the part to "super dish":

Searches for: super - returns everything.
Searches for: super dish - returns everything.
Searches for: superdish - returns nothing.

I was considering breaking apart the actual variable sent and doing an OR
statement, but wanted to check here first to see if anyone has a better way.

We are using SQL server and cold fusion MX 6.1.  Getting ready to upgrade to
7.0 in the next few weeks.

Any help would be greatly appreciated.  I hope I have explained myself!

Thanks,
Greg







~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:231921
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to