其他分享
首页 > 其他分享> > Mybatis plus入门(九):运算符

Mybatis plus入门(九):运算符

作者:互联网

目录

BETWEEN AND

BETWEEN AND

    @RequestMapping("/test4")
    @ResponseBody
    public String test4(){
        QueryWrapper<User> qw = new QueryWrapper<>();
        qw.select("id","name").between("age",20,25)
                .orderByAsc("role_id","id");
        List<User> plainUsers = userMapper.selectList(qw);
        // 方式2
        LambdaQueryWrapper<User> lwq = new LambdaQueryWrapper<>();
        lwq.select(User::getId,User::getName).between(User::getAge,20,25)
                .orderByAsc(User::getRoleId,User::getId);
        List<User> lambdaUsers = userMapper.selectList(lwq);
        return "success";
    }

# 控制台
SELECT id,name FROM user WHERE (age BETWEEN ? AND ?) ORDER BY role_id ASC,id ASC
SELECT id,name FROM user WHERE (age BETWEEN ? AND ?) ORDER BY role_id ASC,id ASC

标签:QueryWrapper,LambdaQueryWrapper,selectList,运算符,plus,User,Mybatis,id,ASC
来源: https://www.cnblogs.com/chniny/p/16202594.html