On 8/21/01, Chris Geanious penned:
>Greetings,
>Am constructing a db search using (among other things) a form text area for
>keywords.  In the data base there is a KeyWords field which contains a
>comma delimited list of keywords for each entry.
>
>I have a query which loops over the form text box entries.  How do I then
>loop over the database keyword fields to check for a match?  I am a little
>stuck.  Any suggestions, code snippets, links to sites would be greatly
>appreciated.

There's really no way that I know of to loop over a field in a 
database without first pulling out the data and looping over that.

Since you are using a comma delimited list, I'd add a comma to the 
beginning and end of the field on the insert so it looks like:

,keyword1,keyword or phrase,keyword3,etc,

Then:

WHERE somefield = '#somevalue#' and
(<cfloop index="mycriteria" list="#criteria#">
(keywords LIKE ',#Trim(mycriteria)#,' OR</cfloop> 0=1)
-- 

Bud Schneehagen - Tropical Web Creations

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
954.721.3452

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to