Solved

Loop a Query

Posted on 2008-06-11
3
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:msfletch
ID: 21763502
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
ID: 21763511
Or just include the lidt directly:

CID IN (#CIDS#)

0
 

Author Closing Comment

by:usky1
ID: 31466295
Works great thanks for the quick help.
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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