【JavaEE】MyBatis-Plus 条件构造器速查表

(英文缩写 + 中文含义 + 对应 SQL + 使用示例,直接对照复制就行)

一、等值 / 不等值条件

方法名 英文全称 中文含义 对应 SQL 使用示例
eq equals 等于 = .eq("age", 18)
ne not equals 不等于 != .ne("gender", 1)
gt greater than 大于 > .gt("age", 20)
ge greater than or equal 大于等于 >= .ge("age", 18)
lt less than 小于 < .lt("age", 30)
le less than or equal 小于等于 <= .le("age", 60)
between between 在区间内 between A and B .between("age", 18, 30)
notBetween not between 不在区间内 not between A and B .notBetween("age", 18, 30)

二、模糊查询 like

方法名 英文含义 对应 SQL 说明
like 包含 like '%值%' .like("username", "zhang")
notLike 不包含 not like '%值%' .notLike("username", "test")
likeLeft 以...结尾 like '%值' 左边有百分号
likeRight 以...开头 like '值%' 右边有百分号

三、空值判断

方法名 中文含义 对应 SQL
isNull 字段为 NULL is null
isNotNull 字段不为 NULL is not null

四、集合查询 in / not in

方法名 中文含义 对应 SQL 使用示例
in 在列表中 in (...) .in("id", List.of(1,2,3))
notIn 不在列表中 not in (...) .notIn("id", List.of(4,5,6))

五、逻辑条件 and / or

方法名 作用 使用场景
and 并且(默认连接就是 and) 多条件直接链式调用
or 或者 拼接 or 条件,会自动加括号
nested 嵌套条件 用于复杂括号分组

六、排序

方法名 作用 示例
orderByAsc 升序排序 .orderByAsc("age", "id")
orderByDesc 降序排序 .orderByDesc("create_time")

七、Lambda 写法对照(推荐)

普通写法:

java 复制代码
.eq("user_id", 1)
.like("username", "min")

Lambda 写法(不易写错):

java 复制代码
.eq(UserInfo::getUserId, 1)
.like(UserInfo::getUsername, "min")
相关推荐
我命由我1234529 分钟前
执行 Gradle 指令报错,无法将“grep”项识别为 cmdlet、函数、脚本文件或可运行程序的名称
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
从此以后自律1 天前
MyBatis-Plus 内置分页、PageHelper 自定义分页
mybatis
4154111 天前
MyBatis-Plus + PostGIS 实战(1.1):Geometry 字段在 Swagger 中的优雅展示
java·mybatis·postgis
光学补偿1 天前
文件IO的前世今生
开发语言·学习·面试·java-ee
她说..1 天前
Apache Commons Lang3 Pair 完整版实战详解
java·spring·java-ee·apache·springboot
4154112 天前
MyBatis-Plus + PostGIS 实战一(基础篇)
java·mybatis·postgis
Wang's Blog2 天前
Java框架快速入门:深入MyBatis-Plus高级DML操作(ID策略·逻辑删除·乐观锁)
java·数据库·mybatis
我命由我123453 天前
Android Studio - Android Studio 自定义预览尺寸
android·java·ide·java-ee·android studio·android-studio·android runtime
丑八怪大丑3 天前
MyBatis
mybatis
从此以后自律3 天前
MyBatis 与 MyBatis-Plus 完整对比讲解
mybatis