This will not work because you be overwriting "GetRolloverDetails" each time
through the loop.  When you're done you'll only have values from the last
time through.

CF actually gives us a GREAT way to do what you want!  

The function "valuelist" takes the description of a query field (query name
and field name) and returns a list of all data returned for that field,
comma delimited.  You take this list and use it with an "IN" operator in
your SQL statement.  (if the field isn't integers, use the function
"quotedvaluelist")

Your first query (GetSubweb) stays the same.  The second query should be:

<cfquery name="getrolloverDetails" ... >
  SELECT * 
  FROM  mkt_rollovr_subweb_ref
  WHERE id_subweb in (#valuelist(GetSubweb.id_subweb)#)
</cfquery>

Short, sweet, elegant!


> -----Original Message-----
> From: Rosa, Issac [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, October 19, 2000 1:41 PM
> To:   CF-Talk
> Subject:      Query result in another query
> 
> Here's what I'm trying to accomplish.
> 
> I am querying a table that will give multiple values for a field (e.g. id
> =
> 9,4). I need to then use these ids to run another query.
> 
> Here's my current code that does not generate an error, but does not run
> the
> query more than once and only outputs the first ids data.  Any thoughts or
> suggestions would be greatly appreciated.
> 
> This query returns 9 and 4 as id_subweb
> CFQUERY NAME="GetSubweb" DATASOURCE="#dsn#">
> SELECT        id_view, id_subweb
> FROM          mom_category_views
> WHERE username = '#session.username#'
> </cfquery>
> 
> <CFSET subList=ListToArray(#GetSubweb.id_subweb#, ",")> 
> 
> <cfloop index=i from=1 to=#ArrayLen(subList)#>
>       <cfquery name="GetRolloverDetails" datasource="#dsn#">
>               SELECT  *
>               FROM            mkt_rollovr_subweb_ref
>               WHERE   id_subweb = #subList[i]#
>       </cfquery>
> </cfloop>
> 
> <cfoutput query="GetRolloverDetails">
>               #mission_statement# <br>
> </cfoutput>
> 
> 
> If you have any questions or concerns, please feel free to call me at
> 407-514-5021.
> 
> Thank you,
> 
> > Issac Rosa
> > 
> > IT - National Sales & Marketing
> > OLAP Specialist Team Leader
> > Ofc: 407-514-5021
> > Cell: 407-342-0644
> > Fax: 407-514-5988
> > [EMAIL PROTECTED]
> > 
> --------------------------------------------------------------------------
> ----------------------
> Archives: http://www.mail-archive.com/[email protected]/
> Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send
> a message with 'unsubscribe' in the body to
> [EMAIL PROTECTED]
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to