in mysql i trying to verify a valid email but i don't know how to use a regex with constraint i don't want use TRIGGER it is possible??!
1 Answer
In mySql you could use this for valid email or NOT REGEX for find the invalid
select email from your_table where email
REGEXP '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$';
or for ORACLE
SELECT email
FROM your_table
WHERE REGEXP_LIKE (email, '[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}');
but remember is not an absolute solution for this you could find useful this SO post Using a regular expression to validate an email address
4 Comments
ayoub naimi
no i don't went to select from database i wen't add a constraint when i went to insert vales in my table
ScaisEdge
For this you should create trigger, ( see how create trigger) and apply the regexp in answer stackoverflow.com/questions/16005283/…
ayoub naimi
thanks for your help,i'm beginner and i look for a simple method
ScaisEdge
If you want to add constraints to the database solution it is the trigger I do not think there are easier solutions. If you want to use simple solutions to write because you start checking on the values before inserting them in the db
CHECKconstraint so IMHO it seems not possible to do it without trigger.checkconstraints: dev.mysql.com/doc/refman/8.0/en/…