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);
团队五人,专业从事软件开发,接单工作,专注于Java,.Net,PHP