Skip to main content
Inspiring
July 23, 2008
Question

Insert Query Results

  • July 23, 2008
  • 1 reply
  • 318 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.

    1 reply

    Inspiring
    July 23, 2008
    First, do a cfloop over your first query. Inside the loop, have a query that will insert info into the other table one row at a time.

    ex:

    <cfloop query="firstQuery">
    <cfquery name="insertionQuery" datasource="someDatasource">
    insert into mytable (Order_Number, sku, qty, price)
    values ('#Order_Number#','#sku#',#qty#,#price#)
    </cfquery>
    </cfloop>