TitleistDBA
IS-IT--Management
I have identified my duplicate rows.
SELECT *
FROM customer
WHERE (emailaddress IN
(SELECT emailaddress
FROM customer
GROUP BY emailaddress
HAVING (COUNT(emailaddress) > 1)))
Now I need to delete the duplicate rows with the min(id).
That would be the oldest record.
I thought this might do the trick but it didn't.
DELETE customer
WHERE (emailaddress IN
(SELECT emailaddress
FROM customer
GROUP BY emailaddress
HAVING (COUNT(emailaddress) > 1)))
AND ID = (SELECT MIN(ID) FROM customer)
Can anyone help with this?
Thanks
SELECT *
FROM customer
WHERE (emailaddress IN
(SELECT emailaddress
FROM customer
GROUP BY emailaddress
HAVING (COUNT(emailaddress) > 1)))
Now I need to delete the duplicate rows with the min(id).
That would be the oldest record.
I thought this might do the trick but it didn't.
DELETE customer
WHERE (emailaddress IN
(SELECT emailaddress
FROM customer
GROUP BY emailaddress
HAVING (COUNT(emailaddress) > 1)))
AND ID = (SELECT MIN(ID) FROM customer)
Can anyone help with this?
Thanks