案例
根据 非id 两个字段删除
void deleteBatchRelation(@Param("entites") List<AttrAttrgroupRelationEntity> entites);
<delete id="deleteBatchRelation">
delete from pms_attr_attrgroup_relation where
-- 遍历循环删除 item separator是分隔符 or
<foreach collection="entites" item="item" separator="OR">
(attr_id=#{item.attrId} and attr_group_id=#{item.attrGroupId})
</foreach>
</delete>
【多选删除】根据ids
EmployeeController层
//给出接口
@RequestMapping("/delempList")
public String deleteEmp(@RequestBody Integer[] ids){
employeeService.deleteList(ids);
return "success删除";
}
EmployeeService层
//定义接口impl
void deleteList(Integer[] ids);
EmployeeServiceImpl层
public void deleteList(Integer[] ids) {
employeeDao.deleteList(ids);
}
核心数EmployeeDao
<delete id="deleteList" >
delete from employee where id in
<foreach collection="array" item="ids" open="(" separator=","
close=")">
#{ids}
</foreach>
</delete>
模糊查询
<select id="getEmpListByname" resultType="com.springboot10.entity.EmployeeEntity">
SELECT * FROM employee where lastname like CONCAT(CONCAT('%', #{lastname}), '%') or email like CONCAT(CONCAT('%', #{email}), '%')
</select>
标签:void,deleteList,ids,案例,SQL,Mybatis,Integer,id,CONCAT
From: https://blog.51cto.com/u_15993308/6174233