当前位置:网站首页>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
边栏推荐
- mysql URL
- Oauth2 server set up oauth2 authentication service
- MySQL date formatting
- Enterprises love hybrid app development, and applet container technology can improve efficiency by 100%
- "Solution" friend of Vulcan
- Hack the box - File Inclusion module detailed Chinese tutorial
- 脉脉网友出了道 Go 面试题,你能答对吗?
- JS string interception
- Hack the box - Introduction to networking module detailed Chinese tutorial
- JS to get the default language of the current browser
猜你喜欢

Is yuancosmos hype? Or the future
![[MySQL] 08: aggregate function](/img/a3/f58fa50f1f7cf5810a9f00d891cfae.png)
[MySQL] 08: aggregate function

The beta version of move protocol is stable, and it is temporarily decided to expand the scale of the prize pool

Introduction to wechat authorized login third-party app applet method

3587. Connected graph (Jilin University postgraduate entrance examination machine test question)

From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run

Scatter chart - date

Digital collections "chaos", 100 billion market changes are coming?

Look at the most influential infrastructure m-dao of Web3 through the current situation of Dao

Why does the metauniverse need NFT?
随机推荐
Relationship between fork and pipeline
Online lover
【一起上水硕系列】June总结+no 焦虑+July计划+如何考试+如何提升
1、 Midwey addition, deletion, modification and query
[Shangshui Shuo series together] June summary +no anxiety +july plan + how to test + how to improve
Move protocol launched a beta version, and you can "0" participate in p2e
RPC调用方如何实现异步调用:CompletableFuture
Scatter chart - date
JQ native write bullet frame mask layer
Use the bark app to realize the process of pushing messages to mobile phones
Rank 3 and count from 0 to 9. How many times does each number appear in total, and how many times does each number appear in the tens of hundreds,
Encryption market ushers in a new historical cycle. Look at jpex's "stability" and "health"
Treap
mysql SUBSTRING_ Application of index in business scenarios
Clear up some disk space and try again
MySQL index filesort
Dynamic programming & backtracking various deformation problems
Sed add content after a line
The beta version of move protocol is stable, and it is temporarily decided to expand the scale of the prize pool
T-SQL query statement