Solved

How to remove duplicate records from two different tables

Posted on 2008-09-29
3
296 Views
Last Modified: 2012-06-27
HI everybody,

I have two database tables

Animal1
ID                  Type               Name
1                    cat                   felix
2                    dog                   ruff
3                    dog                   rover
4                    dog                   skip
5                    cat                    heathcliff

Animal2
ID                 type                   Name
1                  cat                     felix
4                   dog                   skip
3                  horse                   ED

Now if i have duplicate records in both tables I need to delete the duplicates from the "animal2" table. How can i do that?  Is there a way to write a query to do this?
0
Comment
Question by:RegWood79
3 Comments
 
LVL 15

Accepted Solution

by:
jorge_toriz earned 200 total points
ID: 22601963
DELETE Animal2
WHERE ID IN (SELECT ID FROM Animal1)
0
 
LVL 5

Expert Comment

by:ursangel
ID: 22602985
delete from Animal2 where type in
(select type from animal1
group by type)
0
 

Author Closing Comment

by:RegWood79
ID: 31501418
thanks jorge that's exactly what I was looking for.  
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now