Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7897661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:13:25+00:00 2026-06-03T08:13:25+00:00

I am trying to retrieve and store ID’s for each item retrieved from my

  • 0

I am trying to retrieve and store ID’s for each item retrieved from my table, so I can use these ID’s later. I tried nesting the queries, but this didn’t, work. Here is my first query:

<CFQUERY datasource="MyDSN" name="MAIN2"> SELECT * from order_items where orderID= #orderID#</CFQUERY>

Now, if I output this query it displays, 1 and 117 which are the two ID’s I need.

My next query is:

<CFQUERY datasource="MyDSN" name="MAIN3">select c.catalogueID,
c.product_name,
c.product_price,
c.description,
p.productID

from products p
join product_catalogue c on c.catalogueid = p.catalogueid
where p.productid = "#productID#"</CFQUERY>

But it is telling me that productID is not defined, it is obviously empty. I am just getting started using ColdFusion, so I am not sure the best way to store the values I need so I use them again. I also need to loop the second query to run for each ID 1 and 117, so twice.

Any suggestions on how to accomplish this would be greatly appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:13:27+00:00Added an answer on June 3, 2026 at 8:13 am

    My basic rule is that if I find myself using queries to create other queries or looping over a query to execute other queries; it is time to consider combining the queries.

    I’m not sure what field you are using in the MAIN2 query to feed the MAIN3 query. So, I put in “productID” in the query below. You may have to change it to fit your field name.

    <CFQUERY datasource="MyDSN" name="MAIN3">select c.catalogueID,
    c.product_name,
    c.product_price,
    c.description,
    p.productID
    
    from products p
    join product_catalogue c on c.catalogueid = p.catalogueid
    where p.productid IN (SELECT DISTINCT productID from order_items where orderID= <cfqueryparam value="#orderID#" cfsqltype="CF_SQL_INTEGER">)
    </CFQUERY>
    

    You could also change this query to utilize a “join” to connect [order_items] to the query.

    Lastly, you should use the <cfqueryparam> tag for the where clauses; this helps protect your query from sql injection attacks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to store and retrieve numbers in android so later I can do
I am trying to store and retrieve photos from a MySql database. Can someone
I am using trying to use scifihifi-iphone (from Github) to store and retrieve usernames
I am trying to retrieve the date only from my table and store it
I'm trying to use a web service to store/retrieve info from a remote SQL
I'm trying to retrieve record data from an MS-Access database and store it into
I am trying to use the getIntent value(score) which is retrieve from the previous
I'm stuck trying to retrieve data from an associated model store. Allow me to
I'm trying to retrieve multiple rows from joining two tables where store.itemid = item_list.id.
I am trying to use ResourceBundle#getStringArray to retrieve a String[] from a properties file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.