php中,select * from 表 where '123'(变量) in(字段名)

来源:百度知道 编辑:UC知道 时间:2024/06/24 16:32:23
如,有个表名为mytable,里边有个字段名为aa
ID aa
1 123,1234,1246
2 135,246,123,1234
3 1235,1246
我想用select * from mytable where '123' in(aa)查找aa中有123的记录
用select * from mytable where '246' in(aa)查找aa中有246的记录,用in好象不行,用like会出现不应该出现的值

select * from mytable where instr(concat(',',aa,','),concat(',','123',','))
在aa字段两端加 “,” 然后 找 它是否 包含 “,123,”

如果是想要搜索字符串中含有你要的子串的话,要写'%123%'……