当前位置:网站首页>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
边栏推荐
- The solution of [an error occurred while trying to create a file in the destination directory: access denied] is prompted when installing the software
- Meta tags let search engines search your website
- 【一起上水硕系列】一起提前看看July课程
- [Sheung Shui Shuo series] EE feedback details
- "Explanation" change exchange
- In 2022, how to choose cross end technology solutions?
- pip3 带源安装大全
- On the relationship between C language function name and function pointer
- 「题解」带分数
- Ansible automatic operation and maintenance
猜你喜欢

redis学习一redis介绍及NIO原理介绍

Move protocol global health declaration, step into Web3 in sports

Treap

Why does the metauniverse need NFT?

Realize page return to parent directory based on cookies

Enterprises love hybrid app development, and applet container technology can improve efficiency by 100%

Optimization of MySQL paging query

Play to earn: a new and more promising game paradigm in the future

Is yuancosmos hype? Or the future

Hack the box - Web requests module detailed Chinese tutorial
随机推荐
Typescript -- Generic
Chinese brands in the historical process
Is yuancosmos hype? Or the future
redis学习一redis介绍及NIO原理介绍
Dynamic programming & backtracking various deformation problems
4、 Midway integrates swagger and supports JWT bearers
Wargames NATAS (16-19) problem solving essays
Scatter chart - date
2022.7.11 overall solution
情人节
[wechat applet development (IV)] applet fast actual combat classic problem navigation
Limited and unlimited Games: crypto
Is gamefi in decline or in the future?
Will Plato become the risk target of the meta universe? Platofarm has great opportunities
Digital collections "chaos", 100 billion market changes are coming?
Group by group and get the first data
Typora提示【This beta version of Typora is expired, please download and install a newer version】的解决方案
基于FPGA的VGA字符显示
JS problem summary
Hack the box - File Inclusion module detailed Chinese tutorial