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

时间:2021-11-06 16:17:51
 <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"