Q:

MYSQL Email Validation with Regex not working

i just want to fetch the invalid email addresses from my database, i tried with the following query, but its not working
$sql=mysql_query("SELECT * FROM mytable WHERE email!='' and email NOT REGEXP '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$'");

And the invalid Email is a.bcdefg-3@abccom

A:

It looks like the Richard answer is correct however, it may not works given the collation used.
Therefore, if you have a case sensitive collation, you may want to lowercase your field.
Try this query :
SELECT * FROM `mytable` WHERE `email` NOT REGEXP '^[[:alnum:]._%-\+]+@[[:alnum:].-]+[.][[:alnum:]]{2,4}$';    

I have updated the regex to use character classes instead of character range to avoid lower (or upper) case transformation.
Moreover, in some IDE, you may have to escape "." with two backslashes, therefore I use 
[.]

instead of escaped dot.
I updated again to allow subdomains.
Edited to allow +, thanks to @Charlie Brumbaugh comment.

