当前位置:网站首页>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
边栏推荐
猜你喜欢

Chrome F12 keep before request information network

ECCV2022 | RU&谷歌:用CLIP进行zero-shot目标检测!

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

mysql的union和union all

MySQL——几种常见的嵌套查询

Scrapy + Selenium implements simulated login and obtains dynamic page loading data

redis实现分布式锁的原理

二叉查找树的综合应用

4G采集ModbusTCP转JSON接MQTT云平台

pytorch installation error
随机推荐
函数指针数组
使用GBase 8c数据库的时候,遇到这种报错“[[email protected] ~]$ /home/gbase/script/gha_ctl install -p……
CRT command keys
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
C语言二维数组用一维数组进行调用
MySQL 如何修改SQL语句,去掉语句中的or
2022.8.2-----leetcode.622
罕见的数学天才,靠“假结婚”才得到追求事业的机会
The simplest base64 image stream in js realizes automatic download
二叉查找树的插入
pytorch安装错误
4G采集ModbusTCP转JSON接MQTT云平台
MySQL的分页你还在使劲的limit?
go中select语句
SQL试题
关于GBase 8c数据库的问题,如何解决?
分区分表(一)
几款永久免费内网穿透,好用且简单_内网穿透平台
php中去重二维数组
MySQL的存储过程