SQL Insert Into (Join)

  • Thread starter Thread starter Glenn
  • Start date Start date
G

Glenn

Michel,

Thank you for your reply. However I don't think your
solution is the one I am looking for. I may not have
described the scenario correctly. I have two tables;
Customers and Customer_Address. The tables are in a one
to many relationship; Customers.CustomerID(PK) and
Customer_Address.Customer(FK). Say for example, I have a
*.csv file containing new customer name etc details to be
inserted into Customers table and details of that
customer's address to be inserted into Customer_Address
table. I understand I can JOIN two INSERT statements but
I don't know the syntax. Any clearer??

Reading what I can, I thought it might go something like
this,
but this hasn't worked

INSERT INTO Customers INNER JOIN Customers_Address ON
Customers.UniqueID = Customers_Address.CustomerID
(Customers.LastName, Customers.FirstName,
Customers_Address.Address, Customers_Address.City,
Customers_Address.State,) VALUES 'SMITH','Bill',
'1 Main Street','Maintown', 'Mainstate');



Thanks again

Glenn
 
Hi,


Just one INSERT, it is the SELECT that gets the JOIN. Build the
SELECT with the join, retrieving all the fields, adding constant if you
want:

SELECT list_of_fields_or_expressions
FROM Customers As a INNER JOIN Address As b
ON a.ClientID=b.ClientID

then, prefix the beauty with " INSERT INTO tablename( listOfFields ) "


Hoping it may help,
Vanderghast, Access MVP
 
Back
Top