当获取一个List 集合数据时,需要遍历判断,这个时候就用到了mybatis的标签
public List<TAdmin> selectByIds(@Param("ids") List ids);
collection:指定迭代的集合
item:表示当前从集合中迭代的元素
open:开始字符
close:结束字符
separator:分隔符
原生sql:select id, name, age from student where id in (?,?,?);
<select id="selectByIds" resultType="com.mybatis.demo.mybatis1.bean.TAdmin">
select * from admin where id in
<foreach collection="ids" item="currentId" open="(" close=")" separator=",">
#{currentId}
</foreach>
</select>