学习mysql [charlis]通配符时,出现了查不出结果的情况。
select * from repretentative where name rlike '^[m]%'和select * from repretentative where name rlike '[m]%'都查空。(mssql语法)
将sql语句改为select * from repretentative where name rlike '^[m]'即可。(mysql语法)
因为在Mysql中,[]属于正则模式,所以模糊查询的like不适用了,得使用 ' rlike '或者 ‘regexp’关键词’。
但是在很多博客和论坛中还是有用like成功查询的例子,可能是版本的问题?存疑。