Tom Hazel
Tom Hazel

Reputation: 3502

Scrub email address from Mysql

I have a MySQL database full of user information. I'd like to give it to a contractor to do some analysis, but I don't want to expose all of my user information. My biggest concern now are the email addresses. I would like to keep the email address domain, but anonymize the address. Ideally, I'd like to to it in a SQL script.

So I'd like to take every item in the 'email' column and turn it from '[email protected]' to '[email protected]' and '[email protected]' to '[email protected]'. Any ideas?

Upvotes: 1

Views: 2611

Answers (2)

Serhiy Zaharchenko
Serhiy Zaharchenko

Reputation: 1780

UPDATE YourTable SET EmailColumn = CONCAT( 'xxx', RIGHT(EmailColumn, LENGTH(EmailColumn) - LOCATE('@', user_email) + 1) )

Upvotes: 0

Joe Stefanelli
Joe Stefanelli

Reputation: 135848

UPDATE YourTable
    SET EmailColumn = 'xxx' + RIGHT(EmailColumn, LENGTH(EmailColumn) - LOCATE('@', EmailColumn) + 1)

Upvotes: 7

Related Questions