REGEXP运算符,是正则表达式(regular expression)的缩写,正则表达式在搜索字符串时非常强大,下面是关于它的应用
1.查找名字中包含field的顾客
select *
from customers
where last_name like '%field%'
![](https://img-blog.csdnimg.cn/841fa03689b74cd898ace34d4e07238c.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAd2VpeGluXzUxMTM5Nzk1,size_20,color_FFFFFF,t_70,g_se,x_16)
运用REGEXP运算符,可以这样写,同样可以得出数据
select *
from customers
where last_name regexp 'field'
![](https://img-blog.csdnimg.cn/841fa03689b74cd898ace34d4e07238c.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAd2VpeGluXzUxMTM5Nzk1,size_20,color_FFFFFF,t_70,g_se,x_16)
2.查找姓氏以Brush开头的顾客
^表示查找的字符串必须以什么开头
select *
from customers
where last_name regexp '^brush'