Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • 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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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