S
Slez via AccessMonster.com
I'm trying to write the SQL to import a recordset from linked tables. My
current code is as follows:
INSERT INTO tblProject ( JobNumber, ProjectName, SiteStreetAddress, SiteCity,
SiteState, SiteZip, GCName, GCContact, GCStreetAddress, GCCity, GCState,
GCZip )
SELECT Project.JobNumber, Project.ProjectName, Project.SiteStreetAddress,
Project.SiteCity, Project.SiteState, Project.SiteZip, Project.GCName, Project.
GCContact, Customer.GCStreetAddress, Customer.GCCity, Customer.GCState,
Customer.GCZip
FROM Project, Customer
WHERE (((Project.JobNumber)="065812"));
As you can see, I have records from 2 tables: Project & Customer, that I'm
trying to add to one table: tblProject. What I currently get is all records
from the Customer table, rather than just the one that relates to JobNumber
"065812". I have spent alot of time searching tutorials and examples but
cannot grasp what I need to do to distinguish when the records are from more
than one table. To build on this, I will also need to expand this SQL to
include inserting records into tblItem & tblItemDetail from linked tables
Item and ItemDetail. I want to get the above SQL working before I add to it.
I appreciate any help!
current code is as follows:
INSERT INTO tblProject ( JobNumber, ProjectName, SiteStreetAddress, SiteCity,
SiteState, SiteZip, GCName, GCContact, GCStreetAddress, GCCity, GCState,
GCZip )
SELECT Project.JobNumber, Project.ProjectName, Project.SiteStreetAddress,
Project.SiteCity, Project.SiteState, Project.SiteZip, Project.GCName, Project.
GCContact, Customer.GCStreetAddress, Customer.GCCity, Customer.GCState,
Customer.GCZip
FROM Project, Customer
WHERE (((Project.JobNumber)="065812"));
As you can see, I have records from 2 tables: Project & Customer, that I'm
trying to add to one table: tblProject. What I currently get is all records
from the Customer table, rather than just the one that relates to JobNumber
"065812". I have spent alot of time searching tutorials and examples but
cannot grasp what I need to do to distinguish when the records are from more
than one table. To build on this, I will also need to expand this SQL to
include inserting records into tblItem & tblItemDetail from linked tables
Item and ItemDetail. I want to get the above SQL working before I add to it.
I appreciate any help!