当前位置:网站首页>Leecode-SQL 1527. 模糊查询匹配(模糊查询用法)
Leecode-SQL 1527. 模糊查询匹配(模糊查询用法)
2022-08-03 10:01:00 【风吟Pro】

实际上这个题考的是模糊查询或者是正则匹配
模糊查询版本
select * from Patients where conditions like'% DIAB1%' or conditions like'DIAB1%'
复习一下MySQL模糊查询用法
- 基本字符匹配:
select name from user where name REGEXP ‘1000’;
检索name中包含文本1000的所有行。
select name from user where name REGEXP ‘.000’;
.在正则表达式中表示匹配任意一个字符。
进行OR匹配:
select name from user where name REGEXP ‘1000|2000’;
检索name中包含文本1000或2000的所有行。匹配几个字符之一:
select name from user where name REGEXP ‘[123] Ton’;
[123]定义一组字符,它的意思是匹配1或2或3。
select name from user where name REGEXP ‘[1-3] Ton’;
-用来定义一个范围。
匹配特殊字符:
匹配特殊字符,必须用\为前导,-表示查找-,.表示查找.匹配多个实例:
*: 0个或多个匹配;
+:1个或多个匹配(等于{1,});
?:0个或1个匹配(等于{0,1});
{n}:指定数目的匹配;
{n,}:不少于指定数目的匹配;
{n,m}:匹配数目的范围(m不超过255)。定位符:
^:文本的开始;
$:文本的结尾;
[[:<:]]:词的开始;
[[:>:]]:词的结尾;
在集合中:用来否定该集合,例如[0-9],表示不匹配数字
正则解法,对两种情况进行or,匹配任意一种,第一种是DIAB1结尾,第二种是以空格开头DIAB1
select
patient_id,
patient_name,
conditions
from Patients
where conditions regexp '^DIAB1| DIAB1'
order by patient_id asc
边栏推荐
- MySQL 免安装版的下载与配置教程
- MySQL的主从复制
- js函数防抖和函数节流及其使用场景。
- DOM0, DOM2, DOM3 events
- 2022T电梯修理考试题及答案
- "Easy to use" websites that others don't know, make you more efficient
- VL53L0X V2激光测距传感器 采集距离数据串口输出
- Rabbit and Falcon are all covered, Go lang1.18 introductory and refined tutorial, from Bai Ding to Hongru, the whole platform (Sublime 4) Go lang development environment to build EP00
- 慢 SQL 分析与优化
- 函数指针数组
猜你喜欢

mysql 运行的时候 报错

What exactly does a firmware engineer do?

别人都不知道的“好用”网站,让你的效率飞快

ClickHouse 数据插入、更新与删除操作 SQL

DOM0, DOM2, DOM3 events

投稿有礼,双社区签约博主名额等你赢!

Ultra-detailed Asp.net uses SSL two-way authentication, one article is enough

Rabbit and Falcon are all covered, Go lang1.18 introductory and refined tutorial, from Bai Ding to Hongru, the whole platform (Sublime 4) Go lang development environment to build EP00

Oracle 数据如何迁移到MySQL 图文详细教程

阿里本地生活全域日志平台 Xlog 的思考与实践
随机推荐
Let‘s Encrypt 使用
删除文件夹时,报错“错误ox80070091:目录不是空的”,该如何解决?
SQL exam questions
select statement in go
cmd(命令行)操作或连接mysql数据库,以及创建数据库与表
Oracle数据库表空间整理回收与释放操作
Can't get data for duplicate urls using Scrapy framework, dont_filter=True
MySQL 免安装版的下载与配置教程
LeetCode第三题(Longest Substring Without Repeating Characters)三部曲之二:编码实现
2022T电梯修理考试题及答案
播放量暴涨2000w+,单日狂揽24w粉,内卷的搞笑赛道还有机会
GoogLeNet系列解读「建议收藏」
索引(三)
Promise 2: Key Questions
mysqldump导出提示:mysqldump [Warning] Using a password on the command line interface can be insecure
ImportError: DLL load failed with error code -1073741795
MySQL_关于JSON数据的查询
金先生谈长效生长激素出海与产品力
二叉查找树的插入
MySql的初识感悟,以及sql语句中的DDL和DML和DQL的基本语法