Obviously it depends on your columns, what you consider to be a duplicate and how you decide which of them to keep.
eg, assume you have a table of email addresses which have subscribed to your mailing list. The table contains fields for email address and date it subscribed. You want to delete any duplicate addresses, leaving the earliest date. One way to do this is below:
Code:
CREATE TABLE Emails (
Email varchar(50),
SubsDate datetime
)
DELETE emails
FROM emails e
WHERE subsdate <> (
SELECT MIN(subsdate)
FROM emails
WHERE email = e.email
)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.