Reputation: 21
I have a list of all the zip codes in the united states. I need to delete the zip codes which do not appear in more than one county.
I have created the below query which is able to pull out all the zip codes I do not need, but now I need to delete them.
SELECT zipcode, COUNT(countyname) FROM enrollmy_healthr.`table 10`
group by zipcode having count(zipcode)>1;
Thank you in advance for any assistance you may have.
Regards,
Upvotes: 0
Views: 37
Reputation: 1588
This way could help you
Delete from enrollmy_healthr.`table 10` where zipcode in
(select * from (SELECT e.zipcode FROM enrollmy_healthr.`table 10` e
group by e.zipcode having count(e.zipcode)>1) tmp )
Upvotes: 1