?
Solved

table comparison in Acccess

Posted on 2011-02-10
5
Medium Priority
?
280 Views
Last Modified: 2012-05-11
I have 2 tables (A and B) with the same structure, what is the easiest way to obtain a list of combined record without double counting the row with the same record in a chosen field?
0
Comment
Question by:fitaliano
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 34864459
A union query should do it:


SELECT *
FROM tblContacts
UNION SELECT * FROM tblMoreContacts;

Open in new window

0
 

Author Comment

by:fitaliano
ID: 34864510
How do I ensure that Last Names are not double-counted?
0
 
LVL 77

Expert Comment

by:peter57r
ID: 34864825
Union will eliminate duplicates but the duplication is based on all selected fields.
If you want to base duplication just on one field then you will have to come up with some rules about how you decide which record to keep and which to remove.  You will probably then need a second process to get the final list.
0
 

Author Comment

by:fitaliano
ID: 34864913
Thanks Peter,

can you be more specific?

This is exactly what I would like to do:

I have [Address] and [Last Name] in both table A and B.

I want to obtain a list that combines both tables where the same [Last Name] in A and B is counted only once.  If there is a match between [Last Name] I want table A to win


0
 
LVL 77

Accepted Solution

by:
peter57r earned 2000 total points
ID: 34870324
In that case use your equivalent of...

Select * from tableA
Union
Select * from TableB as B where  not exists (Select Lastname from tableA where TableA.Lastname = B.Lastname)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

765 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