java中mybatis的负责sql写法(模糊查询、单字段下拉多选模糊查询、复合字段下拉多选模糊查询)

<select id="selectSjzgAuditSubmitList" parameterType="SjzgAuditSubmit" resultMap="SjzgAuditSubmitResult">
        <include refid="selectSjzgAuditVo"/>
        <where>
            --单独字段模糊查询
            <if test="problemCharact != null  and problemCharact != ''"> and A.problem_charact like concat(concat('%', #{problemCharact}), '%')</if>
            -- 复合字段模糊下拉查询(该字段存储的是多个下拉选项对应的ID用分号隔开后拼接的字符串,前端通过下拉多选的方式模糊搜索,只要该字段中有筛选条件中的一个下拉选项的ID,就被筛选出来)
            <if test="problemLabelCodes != null  and problemLabelCodes .size() > 0">
                <foreach collection="problemLabelCodes" item="option" open="(" separator=" OR " close=")">
                    A.problem_label_code like concat( #{option},';%')   --开头
                    or  A.problem_label_code = #{option}
                    or  A.problem_label_code like concat(concat('%;', #{option}), ';%')  --中间
                    or  A.problem_label_code like concat('%;', #{option})   --结尾
                </foreach>
            </if>
            -- 单字段模糊下拉查询(字段存储的是单个下拉选项对应的ID,前端通过下拉多选的方式模糊搜索,只要在筛选条件中就被筛选出来)
            <if test="rectifyTypes != null and rectifyTypes.size() > 0">
                A.rectify_type IN
                <foreach item="option" collection="rectifyTypes" open="(" separator="," close=")">
                    #{option}
                </foreach>
            </if>
        </where>
        order by create_time desc
    </select>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值