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