Solved

How to merge two tables on access

Posted on 2008-10-12
3
1,567 Views
Last Modified: 2012-05-05
Hello Experts,
I am in the process of analyzing the customer base against the salary amounts.  I have the following  
Table one
Cust ID      Salary
4556      500
4321      600
4566      100
123      999
1234      456

Table two
Cust ID      Salary
4556      399
54545      999
4566      5000
123456      500
4321      444


I need to have one table that has all the data.  Please note that not all customers in table 1 are in table two and not all customers in table 2 are in table 1.
Therefore I am having a problem joining these two tables.
I would like to have the following
Cust ID      Salary1      Salary2

Where if for example customer 4321 salary in table1 is 600 but  he is not in table 2 so value of zero should be assigned in the new table im trying to create
Thanks
0
Comment
Question by:dina78
3 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 22700619
Create Query1 and save it.

Select custid from table1
Union
Select Custid from table2

Create query2:

Select query1.*, table1.salary as salary1, table2.salary as salary2
from (query1 left join table1 on query1.custid = table1.custid)
left join table2 on query1.custid = table2.custid
0
 
LVL 1

Expert Comment

by:rehan_k99
ID: 22700822
select distinct custid, table1.salary, table2.salary from table1, table2
0
 

Author Closing Comment

by:dina78
ID: 31407106
perfect solution thanks alot
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 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