Solved

Loop a Query

Posted on 2008-06-11
3
218 Views
Last Modified: 2013-12-24
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.dataSource#">
      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>
0
Comment
Question by:usky1
  • 2
3 Comments
 
LVL 4

Expert Comment

by:msfletch
Comment Utility
Try creating a list from the loop and then adding the list to the query like:

<cfquery  name="get_CIDS" datasource="#request.dataSource#">
      SELECT customerno, customer_first1, customer_last1
      FROM cibIDS
      WHERE customerno = <cfqueryparam value="#customerno#" maxlength="6"> AND
            CID IN (#loopList#)
</cfquery>
0
 
LVL 4

Accepted Solution

by:
msfletch earned 500 total points
Comment Utility
Or just include the lidt directly:

CID IN (#CIDS#)

0
 

Author Closing Comment

by:usky1
Comment Utility
Works great thanks for the quick help.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now