Solved

How to merge two tables on access

Posted on 2008-10-12
3
1,572 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

809 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