[EMAIL PROTECTED] wrote: > All, > > I'm trying to figure out how best to pass a list of comma delimited id > (numeric) values to > another query. I'm having trouble with getting the list of id values to not > have a "," (comma) > after the last value in the output. Any help would be very appreciated. > > Should I be using a cfloop instead on the 2nd section below? >
You should be using valuelist... <cfset restults = valuelist(get_rec_4month.recipeID)> (or quotedvaluelist, if dealing with strings) > > <!--- 1 - GET RECIPES FOR PRE SELECTED MONTH AND YEAR ---> > <CFquery name="get_rec_4month" datasource="#datasource#"> > select * > from dbo.tbl_recipe_monthly_winner > where (month(recw_assign_month )= 01) AND (year(recw_assign_month )= 2006) > </CFquery> > > <!--- 2 - OUTPUT VALUES IN QUERY TO GET COMMA DELIMITED LIST OF ID VALUES ---> > <cfoutput query="get_rec_4month"> > <CFSET results = #get_rec_4month.recipeID#,> > </cfoutput> > > <!--- 3 - QUERY TABLES WHERE COMMA DELIMTED LIST IN IN WHERE CLAUSE ---> > <cfquery name="sfc_all_recipes" datasource="#recipes#"> > SELECT *, dbo.recipeingredients.ingredients, dbo.addresses.firstname, > dbo.addresses.lastname, > dbo.recipes.recipeID, dbo.recipes.recipename, dbo.recipes.recipedesc, > dbo.recipes.instructions, dbo.recipes.imageID > FROM dbo.recipes INNER JOIN dbo.addresses ON dbo.recipes.addressID = > dbo.addresses.addressID INNER JOIN > dbo.recipeingredients ON dbo.recipes.recipeID = > dbo.recipeingredients.recipeID > WHERE dbo.recipes.recipeID IN #results# > </cfquery> > But you could also do this as a subquery... <cfquery name="sfc_all_recipes" datasource="#recipes#"> SELECT dbo.recipes.*, dbo.recipeingredients.ingredients, dbo.addresses.firstname, dbo.addresses.lastname, dbo.recipes.recipeID, dbo.recipes.recipename, dbo.recipes.recipedesc, dbo.recipes.instructions, dbo.recipes.imageID FROM dbo.recipes INNER JOIN dbo.addresses ON dbo.recipes.addressID = dbo.addresses.addressID INNER JOIN dbo.recipeingredients ON dbo.recipes.recipeID = dbo.recipeingredients.recipeID WHERE dbo.recipes.recipeID IN (select recipeID from dbo.tbl_recipe_monthly_winner where (month(recw_assign_month )= 01) AND (year(recw_assign_month )= 2006) ) </cfquery> > Thanks. > > D > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262000 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

