《Mysql必读sql like语句通配符百分号、下划线与escape用法》要点:
本文介绍了Mysql必读sql like语句通配符百分号、下划线与escape用法,希望对您有用。如果有疑问,可以联系我们。
导读:在sql查询中,像*和?,sql的like语句中,使用%和_来代表任意多个字符和一个字符
# %代表任意多个字符 select * from user where us...
MYSQL学习在sql查询中,像*和?,sql的like语句中,使用%和_来代表任意多个字符和一个字符
# %代表任意多个字符
select * from user where username like '%huxiao';
select * from user where username like 'huxiao%';
select * from user where username like '%huxiao%';
# %代表一个字符
select * from user where username like '_';
select * from user where username like '______';
select * from user where username like 'huxia_';
select * from user where username like 'h_xiao';
# 要查%或者_,的话?使用escape,转义字符后面的%或_就不作为通配符了,注意前面没有转义字符的%和_仍然起通配符作用
select username from gg_user where username like '%xiao/_%' escape '/';
select username from gg_user where username like '%xiao/%%' escape '/';
转载请注明本页网址:
http://www.vephp.com/jiaocheng/6478.html