

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to mask user email addresses with a different domain in MySQL?
Let us first create a table −
mysql> create table DemoTable1345 -> ( -> UserEmailAddress text -> ); Query OK, 0 rows affected (0.42 sec)
Insert some records in the table using insert command. We have inserted email address here −
mysql> insert into DemoTable1345 values('Carol123@gmail.com'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1345 values('987Sam@gmail.com'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable1345 values('David_Miller@gmail.com'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1345 values('Bob@gmail.com'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1345;
This will produce the following output −
+------------------------+ | UserEmailAddress | +------------------------+ | Carol123@gmail.com | | 987Sam@gmail.com | | David_Miller@gmail.com | | Bob@gmail.com | +------------------------+ 4 rows in set (0.00 sec)
Following is the query to mask user email addresses with different domains in MySQL −
mysql> update DemoTable1345 set UserEmailAddress=replace(UserEmailAddress, '@gmail.com','@amz.com'); Query OK, 4 rows affected (0.18 sec) Rows matched: 4 Changed: 4 Warnings: 0
Let us check the table records once again −
mysql> select * from DemoTable1345;
This will produce the following output −
+----------------------+ | UserEmailAddress | +----------------------+ | Carol123@amz.com | | 987Sam@amz.com | | David_Miller@amz.com | | Bob@amz.com | +----------------------+ 4 rows in set (0.00 sec)
- Related Questions & Answers
- How to select domain name from email address in MySQL?
- Select all email addresses beginning with 5 numeric characters (regular expression) in MySQL
- MySQL query to fecth the domain name from email-id?
- Extracting email addresses using regular expressions in Python
- How to log in as a different user on MySQL?
- How to mask data fields in MySQL?
- Return the addresses of the data and mask areas of a masked array in Numpy
- How to sort domain names in MySQL?
- MySQL CREATE USER with a variable?
- How to create MySQL user with limited privileges?
- How to select everything before @ in an email-id with in MySQL?
- How to update User Logged in Time for a specific user in MySQL?
- How to set different auto-increment ids for two tables with a user-defined variable?
- Select into a user-defined variable with MySQL
- Create a new user with password in MySQL 8?
Advertisements