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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

INSERT INTO (JOIN) 3
SQL Troubles. 1
Add records to a joined table 3
Getting Multiple Queries to work 6
problem with inserting in two tables 2
Insert Into Join 5
INSERT INTO, UPDATE, ADD 5
Insert Into Tbl Error 7

Back
Top