当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Simple understanding of GCD
loadrunner-controller-场景执行run
SQL学习笔记——REGEXP运算符
解决rpc error: code = Unimplemented desc = method CheckLicense not implemented
Open Kylin openKylin automation developer platform officially released
Solve rpc error: code = Unimplemented desc = method CheckLicense not implemented
NowCoderTOP23-27 Binary tree traversal - continuous update ing
Mybaits Frequently Asked Questions Explained
力扣shell刷题
unity-shader-2
初识二叉搜索树
Implement a thread pool
Business-(Course-Chapter-Subsection) + Course Publishing Some Business Ideas
【JWT】JWT 整合
因存在自燃安全隐患,宝马7系和5系紧急召回,合计超过5.7万辆
如何判断自己是否适合IT行业?方法很简单
第六章
Build finished with errors/Executable Not Found
csdn file export to pdf
【LeetCode】36.有效的数独