allEq(全部eq)
// 查询名字为Tom,年龄为28,邮箱为空的人 QueryWrapper<User> queryWrapper = new QueryWrapper<>(); Map<String,Object> map = new HashMap<>(); map.put("name","Tom"); map.put("age",28); map.put("email",null); queryWrapper.allEq(map); // 如果第二个参数填写false,则会忽略value值为null的元素,不进行sql拼接 // queryWrapper.allEq(map,false); userMapper.selectList(queryWrapper).forEach(System.out::println);
eq(=)
// 查询年龄为20 QueryWrapper<User> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("age",20); userMapper.selectList(queryWrapper).forEach(System.out::println);
ne(<>)
// 查询年龄不为20 QueryWrapper<User> queryWrapper = new QueryWrapper<>(); queryWrapper.ne("age",20); userMapper.selectList(queryWrapper).forEach(System.out::println);
gt(>)
// 查询年龄大于20 queryWrapper.gt("age",20);
ge(>=)
// 查询年龄大于等于20 queryWrapper.ge("age",20);
lt(<)
// 查询年龄小于20 queryWrapper.lt("age",20);
le(<=)
// 查询年龄小于等于20 queryWrapper.le("age",20);
between
// 查询年龄10到20之间 queryWrapper.between("age",10,20);
notBetween
// 查询年龄不在10到20之间 queryWrapper.notBetween("age",10,20);
like
// 查询名字中有T的(name like '%T%') queryWrapper.like("name","T");
notLike
// 查询名字中没有有T的(name not like '%T%') queryWrapper.notLike("name","T");
likeLeft
// 查询名字中最后一位是T的(name like '%T') queryWrapper.likeLeft("name","T");
likeRight
// 查询名字中第一位是T的(name like 'T%') queryWrapper.likeRight("name","T");
isNull
// 查询名字为空的 queryWrapper.isNull("name");
isNotNull
// 查询名字不为空的 queryWrapper.isNotNull("name");
in
// 查询年龄在(20,21,22)范围内的 queryWrapper.in("age",20,21,22);
notIn
// 查询年龄不在(20,21,22)范围内的 queryWrapper.notIn("age",20,21,22);
inSql
inSql("age", "1,2,3,4,5,6")--->age in (1,2,3,4,5,6) // 里面可以是一个sql的形式 inSql("id", "select id from table where id < 3")--->id in (select id from table where id < 3)
notInSql
notInSql("age", "1,2,3,4,5,6")--->age not in (1,2,3,4,5,6) // 里面可以是一个sql的形式 notInSql("id", "select id from table where id < 3")--->id not in (select id from table where id < 3)
groupBy(分组)
groupBy("id", "name")--->group by id,name
orderByAsc(升序)
orderByAsc("id", "name")--->order by id ASC,name ASC
orderByDesc(降序)
orderByDesc("id", "name")--->order by id DESC,name DESC
orderBy(排序)
orderBy(true, true, "id", "name")--->order by id ASC,name ASC