mybatis xml映射 where 条件判断

实例:

<select id="getListPage" resultMap="BaseResultMap">
        select
        ru.id,ru.name,ru.code,ru.time,ru.ironmak_id,
        ru.typefrom t_plan_iron ru
    <where>
            <if test="data.type != null and data.type!=''  ">
          /*这是 数值型的判断*/
and r.type = #{data.type} </if> <if test="data.name != null and data.name != '' ">
         /*这是 字符串的判断*/
                and ru.name like  '%${data.name}%'
            </if>
      <if test="data.startTime != null and data.startTime != ''
       and data.endTime != null and data.endTime != ''
         "> /*这是 日期间型的判断*/
          and ru.time  between '${data.startTime}' and '${data.endTime}'
      </if>
</where> </select>
原文地址:https://www.cnblogs.com/luo1240465012/p/15189331.html