数据如图,检索字段为 knowledge_points
-- 直接上代码,用mysql正则函数 REGEXP
SELECT * FROM `question`
where concat(',', knowledge_points, ',') REGEXP ',(41|2|5),'
检索结果如下图
此处附带上多条件检索的mybatis写法
<if test="query.knowledgePointIds != null and query.knowledgePointIds.size() > 0 ">
and concat(',', q.knowledge_points, ',') REGEXP
<foreach collection="query.knowledgePointIds" item="item" index="index" open="',('" close="'),'" separator="'|'">
#{item, jdbcType=VARCHAR}
</foreach>
</if>