>AND (Active = 1) and category in >(SELECT category >FROM dbo.PsycBOOKS ><cfif categories is not "">where Category in ('0' > <cfloop >list="#categories#" index="x"> > ,'#x#' ></cfloop>) ></cfif> >)
Why the subquery? Just use IN with cfqueryparam list="true" SELECT LEFT(PublicationYear, 4) AS [Year], COUNT(PBID) AS BookCount FROM dbo.PsycBOOKS WHERE IsNumeric(PublicationYear) = 1 AND Active = 1 <cfif categories is not ""> AND Category IN ( <!--- .. or use listAppend(categories, "0") ---> <cfqueryparam value="#categories#" list="true" cfsqltype="..."> ) </cfif> GROUP BY LEFT(PublicationYear, 4) ORDER BY [Year] desc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289203 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4