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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.