consider that the % sign is the "wildcard" match for ANSI SQL.  if you put
it after the search term in the LIKE clause (as you did with BEGINS_WITH),
you search for something that has <searchstring><any characters>.  the <any
characters> is the % sign.  now, you want something that will match any
characters before and after the search term.

put the % on both sides of the search term.

like so...

                <cfset WhereClause = WhereClause & " and Title like '%" &
                 form.titleValue & "%'">


-----Original Message-----
From: Doherty,Sean [NCR] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 25, 2002 7:04 PM
To: CF-Talk
Subject: coldfusion search


Hi ... i am a newbie to CF ... I was wondering if some one could help me
figure out how to make a search box that can do a "contains" search ... i
can get the begins with and the equals, but not contains ... see below
thanks!

<cfset WhereClause = "0=0">
<cfif Form.titleValue GT "">
        <cfif Form.titleOperator EQ "EQUALS">
                <cfset WhereClause = WhereClause & "and Title ='" &
                 form.titleValue & "'">
        </cfif>
        <cfif Form.titleOperator EQ "BEGINS_WITH">
                <cfset WhereClause = WhereClause & " and Title like '" &
                 form.titleValue & "%'">
        <cfelse>
                <cfset WhereClause = WhereClause & " and Title like '" &
                 form.titleValue & WHAT DO I PUT HERE TO MAKE CONTAINS
WORK?>
        </cfif>
</cfif>

______________________________________________________________________
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