当前位置:   article > 正文

SQL学习笔记——REGEXP运算符_sql regexp

sql regexp

REGEXP运算符,是正则表达式(regular expression)的缩写,正则表达式在搜索字符串时非常强大,下面是关于它的应用

1.查找名字中包含field的顾客

select *
from customers
where last_name like '%field%'
  • 1
  • 2
  • 3

运用REGEXP运算符,可以这样写,同样可以得出数据

select *
from customers
where last_name regexp 'field'
  • 1
  • 2
  • 3

2.查找姓氏以Brush开头的顾客

^表示查找的字符串必须以什么开头

select *
from customers
where last_name regexp '^brush'
  • 1
  • 2
  • 3

3.查找姓氏以field结尾的顾客

$表示查找的字符串必须以什么结尾

select *
from customers
where last_name regexp 'field$'
  • 1
  • 2
  • 3

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号