当前位置:网站首页>16. Learn MySQL Regular Expressions
16. Learn MySQL Regular Expressions
2022-08-04 14:36:00 【Microservice spring cloud】
MySQL Regular Expression
In the previous chapter we have learned that MySQL can perform fuzzy matching through LIKE ...% .
MySQL also supports the matching of other regular expressions. MySQL uses the REGEXP operator for regular expression matching.
If you know PHP or Perl, it's pretty straightforward, as MySQL's regular expression matching is similar to those of these scripts.
The regular patterns in the table below can be applied to the REGEXP operator.
Instance
After understanding the above regular requirements, we can write SQL statements with regular expressions according to our own requirements.Below we will list a few small examples (table name: person_tbl ) to deepen our understanding:
Find all data starting with 'st' in the name field:
mysql> SELECT name FROM person_tbl WHERE name REGEXP '^st';
Find all data in the name field that ends with 'ok':
mysql> SELECT name FROM person_tbl WHERE name REGEXP 'ok$';
Find all data containing the string 'mar' in the name field:
mysql> SELECT name FROM person_tbl WHERE name REGEXP 'mar';
Finds all data in the name field that begins with a vowel character or ends with the string 'ok':
mysql> SELECT name FROM person_tbl WHERE name REGEXP '^[aeiou]|ok$';
边栏推荐
猜你喜欢
The Internet of things application development trend
《中国综合算力指数》《中国算力白皮书》《中国存力白皮书》《中国运力白皮书》在首届算力大会上重磅发出
SLAM 04.视觉里程计-1-相机模型
属于程序猿的浪漫
电子行业MES管理系统有哪些特殊功能
How to automatically renew the token after it expires?
基于 Next.js实现在线Excel
代码随想录笔记_动态规划_1049最后一块石头的重量II
Google plug-in. Download contents file is automatically deleted after solution
leetcode:250. 统计同值子树
随机推荐
Crawler - action chain, xpath, coding platform use
OAID是什么
MySQL【窗口函数】【共用表表达式】
阿里老鸟终于把测试用例怎么写说的明明白白了,小鸟必看
代码随想录笔记_动态规划_1049最后一块石头的重量II
Rust 从入门到精通04-变量
【问题解决】QT更新组件出现 “要继续此操作,至少需要一个有效且已启用的储存库”
C# 复制列表
解题-->在线OJ(十八)
期货开户之前要谈好最低手续费和交返
用了TCP协议,就一定不会丢包吗?
centos7安装mysql急速版
如何在ubuntu环境下安装postgresql并配置远程访问
leetcode:250. 统计同值子树
Find My技术|防止你的宠物跑丢,苹果Find My技术可以帮到你
Rust from entry to proficient 04-variables
vim 常用操作命令
华为手机切换屏幕效果_华为p40页面切换效果怎么换
1403. 非递增顺序的最小子序列
leetcode:251. 展开二维向量