1、查询构造器:Wrapper
QueryWrapper(LambdaQueryWrapper) 和 UpdateWrapper(LambdaUpdateWrapper)的父类用于生成 sql 的 where 条件, entity 属性也用于生成 sql 的 where 条件. MP3.x开始支持lambda表达式,LambdaQueryWrapper,LambdaUpdateWrapper支持 lambda 表达式的构造查询条件。
QueryWrapper
继承自 AbstractWrapper ,自身的内部属性 entity 也用于生成 where 条件及 LambdaQueryWrapper, 可以通过 new QueryWrapper().lambda() 方法获取
UpdateWrapper
继承自 AbstractWrapper ,自身的内部属性 entity 也用于生成 where 条件及 LambdaUpdateWrapper, 可以通过 new UpdateWrapper().lambda() 方法获取!
2、查询
student_mapper表
以map作为参数条件(记得在实体层指定@TableName注解指定要查询的表名)
查询条件中有null的
等于(Eq)的使用
不等于(ne)的使用
大于(gt)的使用
大于等于(ge)
小于(lt)
小于等于(le)
范围值(between)在两个值范围之间(包括临界值)
不在范围值(notBetween)不在两个值范围之间(包括临界值)
匹配值: like %值%
不匹配值:notLike %值%
likeLeft, likeRight
likeLeft 匹配like %值
likeRight 匹配like值%
isuNull&isnotNull
isNull 判断字段为null
isNotNull 判断字段不为null
in , notIn
in 后面值列表, 在列表中都是符合条件的。
notIn 不在列表中的
注意:in和notIn后面跟的值不要太多,不然会影响数据库的性能
inSql, notInSql
inSql 常用来做子查询 类似 in()
notInSql 类似 notIn()
groupBy 基于多个字段分组
orderByAsc ,orderyByDesc , orderBy
orderByAsc 按字段升序
orderByDesc 按字段降序
orderBy多字段的混合排序
or , and
or 连接条件用 or,默认是 and
and 连接条件用 and
last 拼接 sql 语句
exists ,notExists 常用在子查询中
exists 拼接 EXISTS ( sql 语句 )
notExists 是 exists 的相反操作
3、分页
前提: 配置分页插件,实现物理分页。默认是内存分页
分页查询: