sql 查字段里包含某个字符串

用sql函数find_in_set(str,strlist)

字段名参数以 ”,” 分隔 如: (1,2,6,8) ,查询字段(strlist)中包含(str)的结果,返回结果为null或记录 

id   title
1    1
2    11,1
3    11,5,8
4    7,14,3
5    11,51,4
6    4,21
select * from dede_archives where FIND_IN_SET('1',title) 

这样就查出id=1和id=2,这两条数据

 

你可能感兴趣的:(sql,sql,数据库,mysql)