![]() |
![]() |
||||||
|
|||||||
| Tags: insert, query, results |
![]() |
|
|||
|
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 |
| Sponsored Links |
|
|||
|
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> |
|
|||
|
You should be able to do this entirely within your sql statement too
which would be less intensive on the cf server and faster to execute (fewer connections to the DB): <cfquery datasource="mydsn" name="insertRows"> INSERT INTO mytable(mycol1, mycol2, mycol3, mycol4) SELECT mycol1,mycol2,mycol3,mycol4 FROM otherTable WHERE myCriteria = true </cfquery> Nick |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise