[英]SQL regexp to include NOT in search pattern
我想运行以下查询来搜索电子邮件模式:
select * from users
where email regexp Binary '[a-z]*[0-9][0-9][0-9]@yahoo.com';
我想找到所有具有x字母,3位数字并以@ yahoo.com结尾的电子邮件字符串:
example123@yahoo.com admin754@yahoo.com
但是当前查询还会返回包含3个以上数字的字符串,例如example45653@yahoo.com
如何实现?
最简单的方法是使用not
:
where not (email regexp Binary '[a-z]*[0-9][0-9][0-9]@yahoo.com')
要么
where (email not regexp Binary '[a-z]*[0-9][0-9][0-9]@yahoo.com')
一个警告: email
NULL
值以及原始测试都将失败。
尝试这个:
SELECT * FROM mytable WHERE mycolumn REGEXP "[a-zA-Z]+[[:digit:]]{3}@yahoo\\.com";
现场演示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.