专注于分布式,性能优化,代码之美

mybatis中使用in查询问题

当mybatis中需要查询in这种sql时候 ,需要使用 foreach  标签
使用 分隔符将 in(23,13,233)拼接起来,如下 open="(" separator="," close=")"
sql如下:

<select id="selectStudentInfoByIds" resultMap="BaseResultMap">
select
*
from
student
where id in
<foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
and status != 0
</select>

调用时候代码:
List<StudentDAO>
selectStudentInfoByIds (List<Integer> ids);

posted on 2021-04-06 20:09  xiaohouye  阅读(467)  评论(0编辑  收藏  举报

导航

今日之劳累是为了铸造明日之辉煌,不管年龄多少,都无法阻挡我对软件艺术的追求!