Solved

Finding non-duplicate records

Posted on 2001-07-20
10
225 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

832 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