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