【MyBatis】学习笔记08:批量删除

【Mybatis】学习笔记01:连接数据库,实现增删改

【Mybatis】学习笔记02:实现简单的查

【MyBatis】学习笔记03:配置文件进一步解读(非常重要)

【MyBatis】学习笔记04:配置文件模板

【MyBatis】学习笔记05:获取参数值的两种方式

【MyBatis】学习笔记06:各种查询所返回数据的数据类型

【MyBatis】学习笔记07:模糊查询

[TOC]

    /**
     * 批量删除用户
     * @param ids 用户Id
     * @return 影响的行数
     */
    int deleteMore(@Param("ids") String ids);
<!--    int deleteMore(@Param("ids") String ids);-->
    <delete id="deleteMore">
        delete from t_users where userId in (${ids})
    </delete>

只能使用$ ,不能使用#,且使用$不需要加引号

    @Test
    public void testdeleteMore(){
        SqlSession sqlSession = SqlSessionUtils.getSqlSession();
        SQLMapper mapper = sqlSession.getMapper(SQLMapper.class);
        int list = mapper.deleteMore("5,6");
        System.out.println(list);
    }
posted @ 2022-03-27 22:05  萌狼蓝天  阅读(130)  评论(0)    收藏  举报