Solved

How would you modify a SQL Statement for the addition of another table to join (to filter out records in Access 2003)?

Posted on 2013-01-30
1
282 Views
Last Modified: 2013-01-30
In the following INSERT statement, how would I add the following qualifier:
where (C.Officenumber + C.CustomerNumber) = dbo.tblSpINTMatch.[Account Number]


----------------------------------------------------------------------------------------------------------
INSERT INTO dbo.tblSpINT([Account Number], [Address 1], [Address 2], [Address 3])
SELECT Right(C.OfficeNumber,3) + ' ' + C.CustomerNumber AS [Account Number], UPPER(C.Address1)
As [Address 1], UPPER(C.Address2) As [Address 2],  UPPER(C.Address3) As [Address 3]
FROM dbo.tblStatesAll  As S INNER JOIN (dbo.tblCustomersNew As C  
INNER JOIN dbo.tblProductsNew As P  
ON C.CustomerNumber = P.CustomerNumber AND C.OfficeNumber = P.OfficeNumber)
ON S.StateFS = C.ResStateCode
0
Comment
Question by:zimmer9
1 Comment
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 38836963
2 Ways:

#1:

INSERT INTO dbo.tblSpINT([Account Number], [Address 1], [Address 2], [Address 3])
SELECT Right(C.OfficeNumber,3) + ' ' + C.CustomerNumber AS [Account Number], UPPER(C.Address1)
As [Address 1], UPPER(C.Address2) As [Address 2],  UPPER(C.Address3) As [Address 3]
FROM dbo.tblStatesAll  As S INNER JOIN (dbo.tblCustomersNew As C  
INNER JOIN dbo.tblProductsNew As P  
ON C.CustomerNumber = P.CustomerNumber AND C.OfficeNumber = P.OfficeNumber)
ON S.StateFS = C.ResStateCode
inner join dbo.tblSpINTMatch M on
(C.Officenumber + C.CustomerNumber) = dbo.tblSpINTMatch.[Account Number]


OR


#2:

INSERT INTO dbo.tblSpINT([Account Number], [Address 1], [Address 2], [Address 3])
SELECT Right(C.OfficeNumber,3) + ' ' + C.CustomerNumber AS [Account Number], UPPER(C.Address1)
As [Address 1], UPPER(C.Address2) As [Address 2],  UPPER(C.Address3) As [Address 3]
FROM
dbo.tblSpINTMatch M,
dbo.tblStatesAll  As S INNER JOIN (dbo.tblCustomersNew As C  
INNER JOIN dbo.tblProductsNew As P  
ON C.CustomerNumber = P.CustomerNumber AND C.OfficeNumber = P.OfficeNumber)
ON S.StateFS = C.ResStateCode
where (C.Officenumber + C.CustomerNumber) = M.[Account Number]
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question