mybatis xml中使用where 條件中的in方法


 <select id="queryCount" resultType="cn.bnsr.edu_yun.view.FileView">
      SELECT sum(download_times) as downloadNum ,sum(click_times) as browseNum
      FROM  file_property 
    <if test="_parameter != null">
      WHERE id in 
         <foreach item="item" index="index" collection="list" open="(" separator="," close=")">  
             #{item}  
           </foreach>  
      </if>
  </select>

如上方法使用in,

  注意,傳入的參數是List<Long> ,如果傳入的是array 則需要修改紅色部分定義為 collection="array" 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM