Skip to main content
Inspiring
July 23, 2008
Question

Insert Query

  • July 23, 2008
  • 3 replies
  • 464 views
Hello - What is the best method to take the results of a query that
returns a series of records based on an order number (ex. Order Number
is 1234ABC and returns 5 records that include sku, qty and price) and
insert the query results into a db table?

Any help is appreciated.

Thanks,
Steve
This topic has been closed for replies.

3 replies

Inspiring
July 23, 2008
This is actually a case where a customer has placed a previous order
(which is where the order number comes from) and would like to duplicate
the order. The previous order is displayed on the page with the option
to duplicate (submit reorder). Make more sense?

Dan Bracuk wrote:
> If the data is already coming from a db query, the best method might be to do nothing.
Inspiring
July 23, 2008
quote:

Originally posted by: Newsgroup User
This is actually a case where a customer has placed a previous order
(which is where the order number comes from) and would like to duplicate
the order. The previous order is displayed on the page with the option
to duplicate (submit reorder). Make more sense?

Dan Bracuk wrote:
> If the data is already coming from a db query, the best method might be to do nothing.


That would make it a new order then, would it not?

The sql would be something like
insert into mytable
(order_number, field2, etc)
select 'new_order_number', field2, etc
from mytable
where order_number = 'old_order_number'
Inspiring
July 23, 2008
Steve Miller wrote:
> Hello - What is the best method to take the results of a query that
> returns a series of records based on an order number (ex. Order Number
> is 1234ABC and returns 5 records that include sku, qty and price) and
> insert the query results into a db table?
>
> Any help is appreciated.
>
> Thanks,
> Steve

This is a bit of a strange question as worded. You are querying a
database getting data from one or more tables. And you now want to
store this data into a database table?

Anyway, the basic idea of putting repeating data into a table is simple.
Loop over data. Build <cfquery...> insert SQL block for each iteration.
Rinse. Repeat.

Inspiring
July 23, 2008
If the data is already coming from a db query, the best method might be to do nothing.