mybatis-plus 条件参数说明

 

// 条件构造器1
@Test
publicvoidtestFindWrapper1() {
    // 查询年龄小于25或年龄大于30的人
    QueryWrapper<Student>queryWrapper=new QueryWrapper<>();
    queryWrapper.lt("age",25).or().gt("age",30);
List<Student>students=studentMapper.selectList(queryWrapper);
students.forEach(System.out::println);

// 查询性别为女,且年龄小于等于35的数据
QueryWrapper<Student>queryWrapper=new QueryWrapper<>();
queryWrapper.eq("gender","f").le("age",35);
List<Student>students=studentMapper.selectList(queryWrapper);
students.forEach(System.out::println);

 

// 查询名字包含"小"的学生,按照年龄升序排序
QueryWrapper<Student>queryWrapper=new QueryWrapper<>();
queryWrapper.like("sname","小").orderByAsc("age");
List<Student>students=studentMapper.selectList(queryWrapper);
students.forEach(System.out::println);

 

posted @ 2024-09-19 17:26  MvloveYouForever  阅读(11)  评论(0编辑  收藏  举报