MySql的like語句中的通配符:百分號、下劃線和escape %代表任意多個字符 Sql代碼 www.2cto.com select * from user where username like '%huxiao'; select * from user where username like 'huxiao%'; select * from user where username like '%huxiao%'; _代表一個字符 Sql代碼 select * from user where username like '_'; select * from user where username like 'huxia_'; select * from user where username like 'h_xiao'; 如果我就真的要查%或者_,怎麼辦呢?使用escape,轉義字符後面的%或_就不作為通配符了,注意前面沒有轉義字符的%和_仍然起通配符作用 Sql代碼 select username from gg_user where username like '%xiao/_%' escape '/'; select username from gg_user where username like '%xiao/%%' escape '/';