MySQL NOT REGEXP Operator
Updated on
MySQL NOT REGEXP selects a string when it does not match a regular expression. It is equivalent to NOT (expr REGEXP pattern) and is a synonym of NOT RLIKE. See the MySQL regular expression reference.
Syntax
expr NOT REGEXP pattern
Example
This query returns rows whose code is not made entirely of digits:
SELECT code
FROM products
WHERE code NOT REGEXP '^[0-9]+$';
For individual expressions, NOT REGEXP returns 1 when there is no match and 0 when there is a match. If expr or pattern is NULL, the result is NULL. String matching follows the arguments’ character set and collation; use REGEXP_LIKE() with match_type c or i when you need explicit case behavior.