MyBatis-Plus 中的 Wrapper 类可以用于构造复杂的查询条件,以便于生成更灵活的 SQL 查询语句。下面总结了一些常
见的 Wrapper 查询条件
queryWrapper.eq("column_name", value);
queryWrapper.ne("column_name", value);
queryWrapper.gt("column_name", value);
queryWrapper.ge("column_name", value);
queryWrapper.lt("column_name", value);
queryWrapper.le("column_name", value);
queryWrapper.like("column_name", "keyword");
wrapper.notLike("column_name", "keyword");
queryWrapper.likeLeft("column_name", "keyword");
queryWrapper.likeRight("column_name", "keyword");
queryWrapper.isNull("column_name");
queryWrapper.isNotNull("column_name");
queryWrapper.in("column_name", value1, value2);
queryWrapper.notIn("column_name", value1, value2);
queryWrapper.between("column_name", minValue, maxValue);
queryWrapper.notBetween("column_name", minValue, maxValue);
queryWrapper.apply("column_name = {0}", value);
queryWrapper.nested(i -> i.eq("column1", value1).or().eq("column2", value2));
queryWrapper.or(i -> i.eq("column1", value1).eq("column2", value2));
queryWrapper.and(i -> i.eq("column1", value1).eq("column2", value2));
queryWrapper.orderByAsc("column_name1", "column_name2");
queryWrapper.orderByDesc("column_name1", "column_name2");
wrapper.groupBy("column1", "column2");
wrapper.having("SUM(column1) > 100");
wrapper.exists("SELECT 1 FROM other_table ot WHERE ot.column_name = table_name.column_name");
wrapper.notExists("SELECT 1 FROM other_table ot WHERE ot.column_name = table_name.column_name");
wrapper.last("LIMIT 10");
LambdaQueryWrapper<User> wrapper = Wrappers.lambdaQuery();
wrapper.likeRight(User::getName, "A")
.or()
.likeLeft(User::getEmail, "@gmail.com")
.and(qw -> qw.gt(User::getAge, 25).lt(User::getAge, 35));