Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 3 of 3 total |
query advice |
Sun, Aug 19 2007 7:31 PM | Permanent Link |
Jim Margarit | Is there a single query that will add a record to table B for every record in table A?
For example: Add a record consisting of accountID and parameter :FuelSurcharge to an invoice table for every existing account. Right now, I select all accounts and loop through them and add records to the invoice table. Seems like there should be an SQL way to do it. Thanks, Jim |
Sun, Aug 19 2007 10:24 PM | Permanent Link |
"Robert" | "Jim Margarit" <mailATdrmargarit.com> wrote in message news:3D844BA7-0129-4CE3-84F8-4FFB7C29F333@news.elevatesoft.com... > Is there a single query that will add a record to table B for every record > in table A? > > For example: Add a record consisting of accountID and parameter > :FuelSurcharge to an invoice table for every existing account. > > Right now, I select all accounts and loop through them and add records to > the invoice table. Seems like there should be an SQL way to do it. > INSERT INTO "Customer" (CustNo, Company) SELECT CustNo, Company FROM "OldCustomer" |
Mon, Aug 20 2007 11:14 AM | Permanent Link |
Jim Margarit | Robert wrote:
> "Jim Margarit" <mailATdrmargarit.com> wrote in message > news:3D844BA7-0129-4CE3-84F8-4FFB7C29F333@news.elevatesoft.com... >> Is there a single query that will add a record to table B for every record >> in table A? >> >> For example: Add a record consisting of accountID and parameter >> :FuelSurcharge to an invoice table for every existing account. >> >> Right now, I select all accounts and loop through them and add records to >> the invoice table. Seems like there should be an SQL way to do it. >> > > INSERT INTO "Customer" (CustNo, Company) > SELECT CustNo, Company > FROM "OldCustomer" > > > After a lot of post searching, it turned out to be (off the top of my head, not cut and paste): INSERT INTO invoice (acctID,fee) select acctID, cast(:fuelSurcharge as integer) from account which is much much much faster than looping through and inserting. I never would have pulled that out from any of the help files. Getting the parameter to work was the hard part. Jim Margarit |
This web page was last updated on Tuesday, May 7, 2024 at 02:40 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |