Solved

table comparison in Acccess

Posted on 2011-02-10
5
265 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
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…

733 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