当前位置:网站首页>Wildcards in MySQL like statements: percent, underscore, and escape
Wildcards in MySQL like statements: percent, underscore, and escape
2022-07-24 08:44:00 【Bird of paradise in the wind】
MySql Of like The wildcard in the statement : Percent sign 、 Underline and escape
%: Represents any one or more characters . Matches characters of any type and length .
Sql Code
select * from user where username like ‘%huxiao’;
select * from user where username like ‘huxiao%’;
select * from user where username like ‘%huxiao%’;
in addition , If you need to find out u_name There is already “ 3、 ... and ” And then there is “ cat ” The record of , Please use and Conditions
SELECT * FROM [user] WHERE u_name LIKE ‘% 3、 ... and %’ AND u_name LIKE ‘% cat %’
If you use SELECT * FROM [user] WHERE u_name LIKE ‘% 3、 ... and % cat %’
Although we can find out “ Three legged cat ”, But you can't find the right ones “ Zhang maosan ”.
_: Represents any single character . Match a single arbitrary character , It is often used to limit the character length of an expression :( Can represent a Chinese character )
Sql Code
select * from user where username like ‘_’;
select * from user where username like ‘huxia_’;
select * from user where username like ‘h_xiao’;
If I really want to check % perhaps _, What shall I do? ? Use escape, After the escape character % or _ It's not a wildcard , Note that there is no escape character before % and _ It still works as a wildcard
Sql Code
select username from gg_user where username like ‘%xiao/_%’ escape ‘/’;
select username from gg_user where username like ‘%xiao/%%’ escape ‘/’;
Reproduced source :http://www.cnblogs.com/wicub
边栏推荐
- Relationship between fork and pipeline
- 「题解」带分数
- Move protocol launched a beta version, and you can "0" participate in p2e
- Xiaobai learns oauth2
- Beandefinition three ways to load beans
- Recursive performance test
- [Sheung Shui Shuo series] EE feedback details
- Change of sheetname
- Move protocol starts with running and builds a healthy ecosystem of sports
- Chinese brands in the historical process
猜你喜欢

Optimization of MySQL paging query

【一起上水硕系列】June总结+no 焦虑+July计划+如何考试+如何提升

阻塞队列BlockingQueue 源码解析(ArrayBQ和LinkedBQ)

Overseas media, domestic we media, media publicity

【一起上水硕系列】Final RAD-new literacies
![[Sheung Shui Shuo series] EE feedback details](/img/19/5a80d5ef80d75be74b7ce08d6df058.png)
[Sheung Shui Shuo series] EE feedback details

Read and understand move2earn project - move

Four data interaction modes of go grpc

Crypto giants all in metauniverse, and platofarm may break through

What is the difference between domestic "rocket heart" artificial heart and different artificial heart?
随机推荐
JS to get the default language of the current browser
POI operation excel collation
Typora prompt [this beta version of typora is expired, please download and install a new version]
安装软件时提示【An error occurred while trying to create a file in the destination directory: 拒绝访问】的解决方法
On express framework
Clear up some disk space and try again
Using golang to implement RPC (1)
How RPC callers implement asynchronous calls: completable future
Why does the metauniverse need NFT?
JMX Console 未授权访问漏洞
MySQL date formatting
Bit.store, which has attracted much attention, is at a glance of the latest developments
Four data interaction modes of go grpc
Web3≠NFT? A digital Renaissance?
In 2022, how to choose cross end technology solutions?
Classic problems of binary tree
SQL learning
Look at the most influential infrastructure m-dao of Web3 through the current situation of Dao
网络情人
Take out the string in brackets