• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

How to remove duplicate records from two different tables

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
RegWood79
Asked:
RegWood79
1 Solution
 
jorge_torizResearch & Development ManagerCommented:
DELETE Animal2
WHERE ID IN (SELECT ID FROM Animal1)
0
 
ursangelCommented:
delete from Animal2 where type in
(select type from animal1
group by type)
0
 
RegWood79Author Commented:
thanks jorge that's exactly what I was looking for.  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now