查询条件
条件 | 说明 |
---|---|
allEq | 基于 map 的比较 |
eq | 等于 = |
ne | 不等于 <> |
gt | 大于 > |
ge | 大于等于 >= |
lt | 小于 < |
le | 小于等于 < |
between | BETWEEN 值1 AND 值2 |
notBetween | NOT BETWEEN 值1 AND 值2 |
like | LIKE ‘%值%’ |
notLike | NOT LIKE ‘%值%’ |
likeLeft | LIKE ‘%值’ |
likeRight | LIKE ‘值%’ |
isNull | 字段 IS NULL |
isNotNull | 字段 IS NOT NULL |
in | 字段 IN (value1, value2, …) |
notIn | 字段 NOT IN (value1, value2, …) |
inSql | 字段 IN (sql 语句) inSql(“age”, “1,2,3”) -> age in (1,2,3) inSql(“id”, “select id from student where id < 3”) -> id in (select id from student where id < 3) |
notInSql | 字段 NOT IN (sql 语句) |
groupBy | GROUP BY 字段 |
orderByAsc | 升序 ORDER BY 字段, … ASC |
orderByDesc | 降序 ORDER BY 字段, … DESC |
orderBy | 自定义字段排序 orderBy(true, true, “id”, “name”) -> order by id ASC, name ASC |
having | 条件分组 |
or | OR 语句,拼接 + OR 字段=值 |
and | AND 语句,拼接 + AND 字段=值 |
apply | 拼接 sql |
last | 在 sql 语句后拼接自定义条件 |
exists | 拼接 EXISTS(sql语句) exists(“selece id from student where age = 1”) -> exists(selece id from student where age = 1) |
notExists | 拼接 NOT EXISTS(sql语句) |
nested | 正常嵌套 不带 AND 或者 OR |
例子:
QueryWrapper<ResultsrankEntity> wrapperList = new QueryWrapper<>();
//取出同一个学校的同一个专业一样的放到一个列表里面
wrapperList.eq("choosemajor",resultsrank.getChoosemajor());
wrapperList.eq("chooseschool",resultsrank.getChooseschool());
wrapperList.orderByDesc("sumnumber+0");
List<ResultsrankEntity> choosemajorList =resultsrankDao.selectList(wrapperList);
注意排序数据库里面存储的是字符串类型的数字的话排序需要"+0"才好使,如上面代码