mybatis参数为List时候

这篇博客详细介绍了如何在MyBatis中利用List参数进行复杂的SQL查询。通过一个具体的查询示例,展示了如何在XML映射文件中使用<foreach>标签来处理集合类型的参数,实现条件过滤,包括根据多个字段匹配和in操作。内容涵盖了内连接、左连接以及动态SQL的使用,适合对MyBatis查询优化感兴趣的读者。
摘要由CSDN通过智能技术生成

mybatis在使用参数为list时候

<select id="getAllSupplierFileMessage" resultType="com.benleiyun.adminbiz.BO.ReturnFileMessage">
        SELECT
            file.id,
            file.file_name,
            file.file_type,
            file.file_url,
            file.created_by,
            file.updated_time,
            operation.id AS operationId,
            operation.pro_name,
            type.file_type AS type
        FROM
            pro_file file
                INNER JOIN pro_epiboly_record record ON file.biz_id = record.pro_id
                LEFT JOIN pro_file_type type ON type.id = file.file_type
                LEFT JOIN pro_operation operation ON file.biz_id = operation.id
        <where> file.del_flag = '0'
            <if test="queryFileMessage.supName != null and queryFileMessage.supName !=''">and record.sup_name = #{queryFileMessage.supName}</if>
            <if test="queryFileMessage.fileName != null and queryFileMessage.fileName !=''">and file.file_name = #{queryFileMessage.fileName}</if>
            <if test="queryFileMessage.fileType != null and queryFileMessage.fileType !=''">and file.file_type = #{queryFileMessage.fileType}</if>
            <if test="queryFileMessage.proName != null and queryFileMessage.proName !=''">and operation.pro_name = #{queryFileMessage.proName}</if>
            <if test="queryFileMessage.proIds != null">
                AND operation.id in
                <foreach item="item" index="index" collection="queryFileMessage.proIds"
                         open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值