Mybatis的分支选择:
<choose>
<when test="patientNo != null and patientNo != ''">
and ipi.patient_no = #{patientNo}
</when>
<otherwise>
<if test="patientName != null and patientName != ''">
and ipi.patient_name like CONCAT('%',#{patientName},'%')
</if>
<trim prefix="where" prefixOverrides="and">
<if test="printTimeBegin != null and printTimeBegin != ''">
and mrm.print_time >= #{printTimeBegin}
</if>
<if test="printTimeEnd != null and printTimeEnd != ''">
and mrm.print_time <= #{printTimeEnd}
</if>
</trim>
</otherwise>
</choose>
循环In:
<if test='depts!=null and depts.size()>0'>
and ioh.department_id IN
<foreach item="item" index="index" collection="depts" open="(" separator="," close=")">
#{item}
</foreach>
</if>
原文地址:https://www.cnblogs.com/kibana/p/11299702.html
时间: 2024-10-13 19:47:19