complex insert statement?

Results 1 to 2 of 2

Thread: complex insert statement?

  1. #1
    Join Date
    Dec 1969

    Default complex insert statement?

    im not that experienced at sql..<BR>anyways this is the problem im facing ..<BR><BR>Im indicating the primary keys in each table along with the table with a &#039;-&#039;<BR><BR>ive 1 Main Table(Invoices - InvoiceGID) and 3 Other Tables<BR>Companys - CompanyGID; <BR>Branches - BranchGID;<BR>Orders - OrderGID<BR><BR>The 3 Three Tables are related to the main Invoice table using these 3 relationship tables<BR>CompanyInvoice - CompanyFID,InvoiceFID; <BR>BranchInvoice - BranchFID,InvoiceFID; <BR>OrderInvoice - OrderFID,InvoiceGID<BR><BR><BR>CompanyGID is linked to CompanyFID & InvoiceGID is linked to InvoiceFID in the relationship table<BR>CompanyInvoice<BR><BR>Now consider im entering a row into the Invoice Table (The Primary Autogenerated key is InvoiceGID)<BR>for a BranchGID = 345, I can insert the data into Invoice Table fine.. but how do i relate the<BR>BranchFID with the new Invoice Table Row in the Relationship table BranchInvoice.<BR><BR>I mean how do i put the value of BranchFID(345) & InvoiceFID(now autogenerated whose value i dont know)<BR>into the relationship table while inserting the new row into Invoice table itself<BR><BR>how do i do this .. or is there some other way or is there a problem with how i understood the concept<BR><BR>if im not clear at explaining the problem pls do tell ...

  2. #2
    Join Date
    Dec 1969

    Default RE: complex insert statement?

    Sounds like you need to get the PK value of a newly inserted record?<BR><BR>There is a good FAQ on this. Start here:<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts