Skip to content
Advertisement

SQL update : deduplication of email address by adding + ID before @

I’m trying to update a clients table in mySQL containing duplicate email addresses and a unique custom_ID. I would like to change duplicate email addresses by adding a ‘+’ and customer_ID before the @ sign, but only for the email addresses that are not unique.

Advertisement

Answer

You can use update with window functions and a join:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement