Mybatis plus入门(九):运算符
作者:互联网
目录
BETWEEN AND
- 使用BaseMapper接口的selectList方法,传入参数QueryWrapper
- 使用BaseMapper接口的selectList方法,传入参数LambdaQueryWrapper
BETWEEN AND
- 使用BaseMapper接口的selectList方法,传入参数QueryWrapper
- 使用BaseMapper接口的selectList方法,传入参数LambdaQueryWrapper
@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