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>

 


免责声明!

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



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