ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
#### 根据Id删除单条 Mapper接口 ``` void deleteById(@Param("id") String id) throws Exception; ``` Mapper.xml ``` <delete id="deleteById" parameterType="java.lang.String"> DELETE FROM TABLE WHERE id = #{id} </delete> ``` #### 根据Id批量删除 Mapper接口 ``` //批量删除 - 传入数组 void batchDeleteEmps(int[] empno); //批量删除 - 传入List集合 void batchDeleteEmps(List<String> empno); ``` Mapper.xml ``` collection指的是接口中的参数注解,如果没写注解,则数组写array,list写list 1、当collection=”array“时,表名参数为数组。 2、当collection=”list“时,表名参数为集合。 <!-- 批量删除 - 数组 --> <delete id="batchDeleteEmps" parameterType="int"> delete from TABLE where empno in <foreach item="empnoItem" collection="array" open="(" separator="," close=")"> #{empnoItem} </foreach> </delete> <!-- 批量删除 - 集合 --> <delete id="batchDeleteEmps" parameterType="int"> delete from TABLE where empno in <foreach item="empnoItem" collection="list" open="(" separator="," close=")"> #{empnoItem} </foreach> </delete> ```