Wildcards in MySql's like statement: percent sign, underscore and escape
% represents any number of characters
Sql code www.2cto.com
select * from user where username like '%huxiao';
select * from user where username like 'huxiao% ';
select * from user where username like '%huxia%'; _represents
a 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 % or _, what should I do? Using escape, the % or _ after the escape character will not be used as a wildcard. Note that the % and _ without escape characters in front of them still function as wildcards.
Sql code
select username from gg_user where username like '%xiao/_%' escape '/ ';
select username from gg_user where username like '%xiao/%%'
Wildcards in MySql's like statement: percent sign, underscore and escape
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326524180&siteId=291194637
Recommended
Ranking