mybatis like 转义,遍历List


mybatis.xml 中

模糊查询

<if test="studentName != null and studentName !='' ">
    AND stu.student_name LIKE concat(concat("%",#{studentName}),"%")
</if>

 

遍历list:

ClassTrainrelMapper.java

List<ClassTrainRel> queryTrainByIds(@Param("trainIds") List<Integer> trainIds);

 

ClassTrainrelMapper.xml

<select id="queryTrainByIds" resultType="cn.rc.api.entity.ClassTrainRel">
        SELECT
        *
        FROM
        t_class_train_rel
        WHERE
        status = 0
        AND delete_flag = 0
        AND id IN
        <foreach item="item" index="index" collection="trainIds"
                 open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM