Mysql 拼接多个字段作为查询条件查询方法
Posted 张志翔ۤ
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql 拼接多个字段作为查询条件查询方法相关的知识,希望对你有一定的参考价值。
最近工作中需要把多个字段拼接作为查询条件查询,特此记录便于日后查阅。
<select id="listByProgramCodeList" resultType="com.galanz.iot.content.restapi.model.po.RmProgramPo">
SELECT * FROM (
SELECT p.*, CONCAT_WS('#', p.content_code, p.content_version) mix_content_code
FROM rm_program p WHERE p.deleted = 0
) m
<where>
<if test="1 == 1">
AND m.deleted = 0
</if>
<if test="programCodeList!=null and programCodeList.size()>0">
AND m.mix_content_code in
<foreach collection="programCodeList" item="programCode" separator="," open="(" close=")">
#{programCode}
</foreach>
</if>
</where>
</select>
到此 mysql 拼接多个字段作为查询条件查询方法介绍完成。
以上是关于Mysql 拼接多个字段作为查询条件查询方法的主要内容,如果未能解决你的问题,请参考以下文章