当前位置:网站首页>SQL study notes - REGEXP operator
SQL study notes - REGEXP operator
2022-07-31 10:18:00 【xiaoweiwei99】
REGEXP operator, short for regular expression (regular expression), regular expression is very powerful when searching for strings, the following is about its application
1. Find customers whose name contains field
select *from customerswhere last_name like '%field%'
Using the REGEXP operator, it can be written like this, and the data can also be obtained
select *from customerswhere last_name regexp 'field'
2. Find customers whose last name starts with Brush
^ indicates what the search string must start with
select *from customerswhere last_name regexp '^brush'
3. Find customers whose last name ends with field
$ indicates what the search string must end with
select *from customerswhere last_name regexp 'field$'
3. Find customers whose last name contains field or mac
|The symbol indicates multiple search patterns
select *from customerswhere last_name regexp 'brush|mac'
4. Find customers that start with brush, or contain mac, or contain rose
select *from customerswhere last_name regexp '^brush|mac|rose'
5. Find the last name contains e, and it must be preceded by g or i or m
select *from customerswhere last_name regexp '[gim]e'
6. Find the last name contains e, followed by a but a letter in h
select *from customerswhere last_name regexp 'e[a-h]'
Summary:
^ means start of string
$ indicates the end of string
|Represents a logical or, which can give multiple search patterns
[] means any single character listed in parentheses
[-] means any single character within brackets
Exercise
1. Get customers whose name is Elka or Ambur
select *from customerswhere first_name regexp 'elka|ambur'
2. Return customers whose last name ends with ey or on
select *from customerswhere last_name regexp 'ey$|on$'
3. Get customers whose last name starts with my or contains se
select *from customerswhere last_name regexp '^my|se'
4. Return the customer, the last name contains b, then r or u
select *from customerswhere last_name regexp 'b[ru]'
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
猜你喜欢
(C language) program environment and preprocessing
Module eight
Web系统常见安全漏洞介绍及解决方案-XSS攻击
windows平台下的mysql启动等基本操作
Windows系统Mysql8版本的安装教程
Come n times - 07. Rebuild the binary tree
Redis Sentinel原理
The big-eyed Google Chrome has also betrayed, teach you a trick to quickly clear its own ads
What does "chmod 777-R filename" mean?
半个月时间把MySQL重新巩固了一遍,梳理了一篇几万字 “超硬核” 文章!
随机推荐
NowCoderTOP17-22 Binary search/sort - continuous update ing
SQLite3交叉编译
【LeetCode】203.移除链表元素
一种用于保证多方子系统数据一致性的方法
C#多态的实现
Redis的简单使用
Solve rpc error: code = Unimplemented desc = method CheckLicense not implemented
sql力扣刷题八
项目管理工具之燃尽图:动态考核团队工作能力
【LeetCode】21. 合并两个有序链表
Redis集群-哨兵模式原理(Sentinel)
力扣shell刷题
Android安全专题(三)JNI混淆
NowCoderTOP17-22 二分查找/排序——持续更新ing
半个月时间把MySQL重新巩固了一遍,梳理了一篇几万字 “超硬核” 文章!
双链表的插入和删除
The fifth chapter
NowCoderTOP23-27 Binary tree traversal - continuous update ing
解决rpc error: code = Unimplemented desc = method CheckLicense not implemented
Come n times with the sword--05. Replace spaces