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
Solved

Finding non-duplicate records

Posted on 2001-07-20
10
230 Views
Last Modified: 2011-09-20
Hi

    I will seek anyone help. I will like to have a query or be able to filter out for me the non-duplicate records of two tables. EG

I have a table name Client1 no and another table called Client2.Inside have many records of part number.

Client1 table      client2 table
 ac-123             ftx-454
 23-tt              23-tt
 tg-t               tg-t
 er-45              hg-33
.......
and many others. So how can i able to run any query or whatever and abel; to filter out only those which are not common and which table it came from. pls enlighten me

Thnaks
roger1
     
0
Comment
Question by:roger1102598
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 2

Expert Comment

by:hotbudare
ID: 6304186
Use:
======================================================
SELECT Query1.Client, Query1.Source
FROM Query1 LEFT JOIN Query2 ON Query1.Client = Query2.Client
WHERE (((Query2.Client) Is Null));
======================================================

WHERE Query1:
======================================================
SELECT Table1.Client, "Table1" AS Source
FROM Table1;
======================================================

AND Query2:
======================================================
SELECT Table2.Client, "Table2" AS Source
FROM Table2;
======================================================


HTH/EQTA
T.S.U. Mario Osorio
Punto Fijo, Falcon, Venezuela

0
 
LVL 54

Expert Comment

by:nico5038
ID: 6304424
roger1,

You use for this the "outer join".
Access has for this the LEFT and RIGHT join. When you use the graphical query editor you can set the direction of a link between tables (just drag and drop the field needed to get a link). Just double-click the line and select option 2 or 3 from the properties window.

This type of relation forces all recordsfrom one table to appear. When you set a "Is Null" in the table the relation is pointing to, then you get only non matching records from the "master table". However, this also needs to be done in the other direction.
Just create a second link pointing the other direction and having the "Is Null" on the field of the other table.
Now to get all non matching in one query you create finally one that combines both like:

select * from qryLeft
union
select * from qryRight;

This has to be typed in the SQL mode, as access doesn't support "graphical unions".

Clear ?

Nic;o)
0
 

Expert Comment

by:senan072100
ID: 6304674
dear roger

ill make ur life easer
1-u open the database windows
2-select new query(wizard)
3-select "find unmatched query wizard"
4-follow it up
5- ur query is ready

may u have any question please let me know
Senan


0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 54

Expert Comment

by:nico5038
ID: 6304774
Senan,

Unmatch can go into two directions:
1) In table1 and NOT in table2
2) In table2 and NOT in table1
This makes it clear why I propose a UNION.

The "easy" wizard will only supply you with ONE.

As roger1 also wants to know from what table the unmatch originates, indicates he wants BOTH.
When you add in "my" qryLeft a cell with "TableFrom:'Table1'"
and in the other a referene to Table2, the UNION will provide all wanted information.

Nic;o)
0
 

Expert Comment

by:senan072100
ID: 6305258
ops sorrey, i got the point
I'll check and let u know
senan
0
 
LVL 6

Expert Comment

by:bknouse
ID: 6306054
Select "Table1", [Part_Num]
From Table1 A
Where Not Exists (Select 1
From Table2 B
Where A.Part_Num = B.Part_Num)

Union

Select "Table2", [Part_Num]
From Table2 C
Where Not Exists (Select 1
From Table1 D
Where C.Part_Num = D.Part_Num)

Brent

0
 
LVL 54

Expert Comment

by:nico5038
ID: 6306068
Hi Brent,

Effectively your proposal will work too, however:
1) Typing this in the QBE editor is not that "easy"
2) Access performs upto 4 times faster on queries as on the subqueries you propose...

Nic;o)
0
 
LVL 30

Accepted Solution

by:
hnasr earned 150 total points
ID: 6306814
'This is a try
'Table1 with field partno
'Table2 with field partno
'your sample data entered
'Client1 table      client2 table
'ac-123             ftx-454
'23-tt              23-tt
'tg-t               tg-t
'er-45              hg-33

SELECT Client1.partno, "Client1" AS [Table]
FROM Client1
WHERE (((Client1.partno) Not In (select partno from client2)));
Union
SELECT Client2.partno, "Client2" AS [Table]
FROM Client2
WHERE (((Client2.partno) Not In (select partno from client1)));

'result
'partno       Table
'ac-123      Client1
'er-45       Client1
'ftx-454     Client2
'hg-33       Client2

'Good luck
0
 
LVL 54

Expert Comment

by:nico5038
ID: 6309172
Why such a cripple subquery solution ?
0
 
LVL 30

Expert Comment

by:hnasr
ID: 6309667
Thanks roger1 that u found my contribution useful.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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 views 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 Access…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

766 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