I have a small email newsletter system and when a new email address is added (through mass import) it defaults to "subscribed
int(11) DEFAULT '1'`".
I then have the below query which looks for the email address and updates any that are already in the table but are un-subscribed :
UPDATE emailData SET subscribed = '0'
WHERE subscribed = '1' and emailAddress IN
(
SELECT emailAddress FROM
(SELECT emailAddress FROM emailData WHERE subscribed = '0' GROUP BY emailAddress) AS tmptable
)
With around 5000 duplicates it takes around 15 seconds to execute (VM Server) and I wanted to know if there was a better / faster way to do this?