![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 a list of invalid email address 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 | John12@gmail.com | | 2 | Carol | Carol@hotmail.com | | 3 | Mike | 123Mike@gmailcom | | 4 | Bob | Bob909hotmail.com | | 5 | David | David@gmail.com | +----+-------+-------------------+ 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