mysql 查询小技巧

数据字段中存放的是id集,形如  1,2,15,35   也可类推json格式

查询时不用拆分了, 用上 instr、concat搜索和连接字符串

查询fids中包含15的

select * from table where instr(concat(',', fids, ','), ',15,') > 0

查询时,多个字段 like 同个值

select * from table where concat(name, title) like '%哈哈%';

猜你喜欢

转载自www.cnblogs.com/qiuphp/p/10598251.html