SQL query to alter email addresses for testing

The SQL query below can be used to change email addresses in test data so they don’t get sent to real people accidentally.

The at sign in the original address is replaced with an asterisk character and then a new domain is appended to the end.

UPDATE test_data SET email = CONCAT(REPLACE(email, '@', '*'), '@trash-mail.com') WHERE email != '';

trash-mail.com is a disposable email service where you don’t even need to create an account.

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA - answer the question below to prove you are human *