Mybatis-Study07-分页

limit 设置分页

  • 接口
List<User> getUserBylimit(Map<String,Integer> map);
  • UserMapper.xml
  <select id="getUserBylimit" resultMap="resultMap" parameterType="map">
        select * from mybatis.user limit #{start},#{page}
    </select>

limit的用法

mysql> SELECT * FROM table LIMIT 5,10; // 检索记录行 6-15   
  
//为了检索从某一个偏移量到记录集的结束所有的记录行,可以指定第二个参数为 -1:    
mysql> SELECT * FROM table LIMIT 95,-1; // 检索记录行 96-last.   
  
//如果只给定一个参数,它表示返回最大的记录行数目:    
mysql> SELECT * FROM table LIMIT 5; //检索前 5 个记录行   
  
//换句话说,LIMIT n 等价于 LIMIT 0,n。 
  • Mytest
   @Test
    public void mytest(){
        SqlSession sqlSession=MybatisUtils.getSqlSession();
        UserMapper userMapper=sqlSession.getMapper(UserMapper.class);
        HashMap<String,Integer> map=new HashMap<String, Integer>();
        map.put("start",0);
        map.put("page",2);
        List<User> userList=userMapper.getUserBylimit(map);
        System.out.println(userList);
        sqlSession.close();
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

QQ星小天才

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值