
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Find Invalid Email Addresses from a Table in MySQL
To find invalid email address, use the below syntax −
SELECT yourColumnName FROM yourTableName WHERE yourColumnName NOT LIKE '%_@_%._%';
The above syntax will give the list of all invalid email addresses. To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table FindInvalidEmailAddressDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(20), -> EmailAddress varchar(40), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.75 sec)
Now you can insert some records in the table using insert command. We have inserted some invalid email address as well for our example. The query is as follows −
mysql> select *from FindInvalidEmailAddressDemo;
The following is the output −
+----+-------+-------------------+ | Id | Name | EmailAddress | +----+-------+-------------------+ | 1 | John | [email protected] | | 2 | Carol | [email protected] | | 3 | Mike | 123Mike@gmailcom | | 4 | Bob | Bob909hotmail.com | | 5 | David | [email protected] | +----+-------+-------------------+ 5 rows in set (0.00 sec)
The following is the query to find the invalid email address −
mysql> select EmailAddress from FindInvalidEmailAddressDemo -> where EmailAddress NOT LIKE '%_@_%._%';
The following is the output with a list of invalid email address −
+-------------------+ | EmailAddress | +-------------------+ | 123Mike@gmailcom | | Bob909hotmail.com | +-------------------+ 2 rows in set (0.00 sec)
Advertisements