> I am building a dynamic query, if a certain form field is selected it adds
> the following statement to the end of the where clause: and table_field in
> ('url.variable')
>
> The table field houses a comma delimited list of numbers and the url
> variable is a comma delimited list as well.
>
> The query will only return a record when both lists (the table
> field and the
> url variable) match; I want it to pull a record when the table field
> contains any part of the URL variable.

I assume that what you mean is that the "table_field" entries contain
entries such as;
first, second, third
and the "url.variable" contains entries such as;
first, third

There's no simple way to do this, what you have to do is to loop through
URL.variable and do SQL "or" with it... the "IN()" won't work for this...

SELECT *
FROM myTable
where
<cfset myCount=0>
<cfloop index="i" list="#URL.variable#">
        <cfset myCount=myCount+1>
        <cfif myCount gt 1>
                or
        </cfif>
        ','+table_field+',' like '%,#i#,%'
</cfloop>

This is for SQL Server...

Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to