方法一
使用like进行模糊查询
语法:
select 字段名称 from 表名 where 字段 like concat('%', '字符串', '%')
sql语句如下:
select * from a where sys_pid like concat('%', 'keyword', '%')
方法二
使用find_in_set函数
语法:
select 字段名称 from 表名 where find_in_set('keyword',字段);
sql:
select * from a where find_in_set('keyword',uid);
注意:查询的内容必须是以逗号分隔并且是精确匹配
方法三
使用locate函数(模糊查询 用 locate 速度快)
语法:
select 字段名称 from 表名 where locate('模糊的keyword',字段);
sql:
select * from a where locate('keyword',uid);
方法四
使用position in (是locate的别名)
语法:
select * from 表名 where position(模糊的keyword in 字段);
sql:
select * from a where position('keyword ' in uid);
方法五
使用instr函数
语法:select 字段名称 from 表名 where INSTR(字段,'模糊的keyword');
sql:
select * from a where INSTR(uid,'keyword')