mysql的正则查询

模糊查询我们都明白  

select * from 表名  where 字段 like '%要查询的数据%'

接下来要说的就是  regexp

查找name字段中以“com”开头的所有数据

select name from 表名  where name regexp '^com'

查找name字段中以’ll‘结尾的的所有数据

select name from 表名  where name regexp 'com$'

查询name字段中包含“xixi”字符串的所有数据

select name from 表名  where name regexp 'xixi'

查找name字段中以元音字符开头或以“ok”字符串结尾的

select name from 表名 where name regexp ’^[aeiou]|pk$‘

猜你喜欢

转载自www.cnblogs.com/companionspace/p/10271286.html