A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

delete duplicates



 
 
Thread Tools Display Modes
  #1  
Old July 1st, 2008, 01:28 PM posted to microsoft.public.access.queries
Darren
external usenet poster
 
Posts: 181
Default delete duplicates

I have one table (table 1) with a column A & B and another table (table 2)
with columns C & D. Now there are duplicates in table 2 on the values in
column C. I need to keep the entries where 1A=2C and 1B=2D and delete the
entries where 1A=2C and 1B does not = 2D

please help
  #2  
Old July 1st, 2008, 01:35 PM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default delete duplicates

So you want to keep the entries where Table1.A = Table2.B and Table1.C =
Table2.D, and delete the non-matching entries from table1?

DELETE FROM Table1
WHERE NOT EXISTS
(SELECT B FROM Table2
WHERE Table1.A = Table2.B and Table1.C = Table2.D);

If subqueries are new, here's an introduction:
http://allenbrowne.com/subquery-01.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Darren" wrote in message
...
I have one table (table 1) with a column A & B and another table (table 2)
with columns C & D. Now there are duplicates in table 2 on the values in
column C. I need to keep the entries where 1A=2C and 1B=2D and delete the
entries where 1A=2C and 1B does not = 2D

please help


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:44 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.