MyBatis 集合操作语法范例:配合SQL的in关键字

Java语法:

    private String[] tagIds;

MyBatis语法

  <delete id="deleteByIds" parameterType="java.util.List" >
delete from BIZ_USER_TAG_REL
where ID in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</delete> <delete id="deleteByUserIdAndTagIds" parameterType="com.yuanchuangyun.framework.entity.system.UserTagRel" >
delete from BIZ_USER_TAG_REL
where USER_ID = #{userId} AND TAG_ID in
<foreach item="item" index="index" collection="tagIds"
open="(" separator="," close=")">
#{item}
</foreach>
</delete>
上一篇:58. N-Queens && N-Queens II


下一篇:HTML5与CSS3权威指南笔记案例1