usky1
asked on
Loop a Query
Can I add the cfloop below to my cfquery statement?
<cfset counter=0>
<cfloop index="i" list="#CIDS#" delimiters=",">
<cfset counter=counter+1>
<cfset "CIDS#counter#"=i>
</cfloop>
<cfloop index="j" from="1" to="#counter#">
<cfoutput>#variables["CIDS " & j]#</cfoutput>
</cfloop>
<cfquery name="get_CIDS" datasource="#request.dataS ource#">
SELECT customerno, customer_first1, customer_last1
FROM cibIDS
WHERE customerno = <cfqueryparam value="#customerno#" maxlength="6"> AND
CID =( How do I loop through the above cfloop and get the values to insert here?)
</cfquery>
<cfset counter=0>
<cfloop index="i" list="#CIDS#" delimiters=",">
<cfset counter=counter+1>
<cfset "CIDS#counter#"=i>
</cfloop>
<cfloop index="j" from="1" to="#counter#">
<cfoutput>#variables["CIDS
</cfloop>
<cfquery name="get_CIDS" datasource="#request.dataS
SELECT customerno, customer_first1, customer_last1
FROM cibIDS
WHERE customerno = <cfqueryparam value="#customerno#" maxlength="6"> AND
CID =( How do I loop through the above cfloop and get the values to insert here?)
</cfquery>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Works great thanks for the quick help.
<cfquery name="get_CIDS" datasource="#request.dataS
SELECT customerno, customer_first1, customer_last1
FROM cibIDS
WHERE customerno = <cfqueryparam value="#customerno#" maxlength="6"> AND
CID IN (#loopList#)
</cfquery>