I hope this is an easy question for you SQL gurus.

I am not sure why someone would want an apostrophe in their last name, :)
but I need to know how to get around that when writing SQL queries
that search records for last names contain apostrophes.

Here is a sample query that loops through the search form
fields and builds a dynamic query:

        <CFQUERY NAME="SearchMembers" DATASOURCE="#DB#">
        SELECT *
        FROM #MemberTable#
        WHERE 0 = 0
        <CFLOOP INDEX=ThisField LIST="#FORM.FIELDNAMES#">
            <CFIF #Evaluate(ThisField)# IS NOT "">
            AND #ThisField# LIKE '#Evaluate(ThisField)#%'
            </CFIF>
        </CFLOOP>
        </CFQUERY>


And here is what gets rendered when we pass some Irish name:

        SELECT *
        FROM Lawyers
        WHERE 0 = 0
        AND LNAME LIKE 'o'donnell'%


And of course, this produces a SQL error.
Anyone have tips for getting around this and still being able
to search for names that contain an apostrophe?

Thanks in advance.

John McKown, VP Business Services
Delaware.Net, Inc.
30 Old Rudnick Lane, Suite 200 Dover, DE 19901
email: [EMAIL PROTECTED]
phone: 302-736-5515
fax: 302-736-5945
icq: 1495432



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to