当前位置:网站首页>MySQL模糊查询可以使用INSTR替代LIKE
MySQL模糊查询可以使用INSTR替代LIKE
2022-07-31 04:10:00 【滴水可藏海】
NSTR()函数返回字符串中子字符串第一次出现的位置。如果在str中找不到子字符串,则INSTR()函数返回零(0)。
下面说明了INSTR函数的语法。
INSTR(str,substr);
INSTR函数接受两个参数:
str 是要搜索的字符串。
substr 是要搜索的子字符串。
MySQL INSTR函数示例
以下语句返回MySQL INSTR字符串中的子字符串SQL的位置。
SELECT INSTR('MySQL INSTR', 'SQL');
执行上面查询语句,得到以下结果:
mysql> SELECT INSTR('MySQL INSTR', 'SQL');
+-----------------------------+
| INSTR('MySQL INSTR', 'SQL') |
+-----------------------------+
| 3 |
+-----------------------------+
1 row in set
例2
SELECT * FROM sys_user where INSTR(name, 'a' )>0
查找用户名称name中包含a的用户,作用类似于LIKE ‘%a%’。
发现其他博客(非作者所写):
Mysql的instr()函数用法
边栏推荐
- The els block moves the boundary to the right, and accelerates downward.
- RESTful api接口设计规范
- (8) Math class, Arrays class, System class, Biglnteger and BigDecimal classes, date class
- Redis 统计用户新增和留存
- A brief introduction to the CheckboxListTile component of the basic components of Flutter
- Automation strategies for legacy systems
- 已解决:不小心卸载pip后(手动安装pip的两种方式)
- C语言表白代码?
- Safety 20220709
- Based on the local, linking the world | Schneider Electric "Industrial SI Alliance" joins hands with partners to go to the future industry
猜你喜欢
Mysql 45 study notes (twenty-four) MYSQL master-slave consistency
Basic knowledge of mysql (2)
MATLAB/Simulink & & STM32CubeMX tool chain completes model-based design development (MBD) (three)
C语言从入门到如土——数据的存储
What skills do I need to learn to move from manual testing to automated testing?
[C language] General method of base conversion
IIR filter and FIR filter
【C语言进阶】文件操作(一)
Mysql 45 study notes (23) How does MYSQL ensure that data is not lost
端口排查步骤-7680端口分析-Dosvc服务
随机推荐
idea工程明明有依赖但是文件就是显示没有,Cannot resolve symbol ‘XXX‘
Postgresql 15 source code analysis (5) - pg_control
$attrs/$listeners
qlib架构
浅识Flutter 基本组件之CheckBox组件
Select the smoke test case, and make the first pass for the product package entering QA
LocalDate加减操作及比较大小
interprocess communication
高等数学---第九章二重积分
C语言从入门到如土——数据的存储
IDEA常用快捷键与插件
日志级别 和 打印log注意
Redis 使用LIST做最新评论缓存
「 每日一练,快乐水题 」1331. 数组序号转换
The use of beforeDestroy and destroyed
安全20220715
Daily practice of LeetCode - palindrome structure of OR36 linked list
Win10 CUDA CUDNN 安装配置(torch paddlepaddle)
ClickHouse:设置远程连接
The application and practice of mid-to-platform brand advertising platform