【02-myBatisPlus的wrapper接口的使用】临文乍了了,彻卷兀若无。这篇文章主要讲述02-myBatisPlus的wrapper接口的使用相关的知识,希望能为你提供帮助。
02-myBatisPlus的wrapper接口的使用。1.直接先上硬菜
序号 | 函数名 | 说明 | 说明/例子 |
---|---|---|---|
1 | eq | 等于= | eq("name","二狗子") ==> wherename = \'二狗子\' |
2 | ne | 不等于 < > | ne("name","二狗子") ==> where name < > \'二狗子\' |
3 | gt | 大于 > | gt("age",18) ==> whereage > 18 |
4 | ge | 大于等于 > = | ge(""age",18) ==> where age > =18 |
5 | lt | 小于 < | lt("age",18") ==> where age < 18 |
6 | le | 小于等于 < = | le("age",18) ==> whereage < =18 |
7 | between | between 值1 and值2 | between("age",18,30) ==> where age between 18 and 30 |
8 | notBetween | not between 值1 and值2 | not between("age",18,30) ==> where age not between 18 and 30 |
9 | like | like \'%值%\' | like("name","二") ==> where name like \'%二%\' |
10 | notLike | not like \'%值%\' | notLike("name","二") ==> where name not like \'%二%\' |
11 | likeLeft | like \'%值\' | likeLeft("name","二") ==> where name like \'%二\' |
12 | likeRight | like \'值%\' | likeRight("name","二") ==> where name like \'二%\' |
13 | isNull | 字段 is null | isNUll(”name“) ==> wherename is null |
14 | isNotNull | 字段 is not null | isNotNull("name") ==> where name is not null |
15 | in | 字段 in ( v0,v1,v2...) | in("age",{1,2,3}) ==> where age in (1,2,3) |
16 | notIn | 字段 not in(v0,v1...) | notIn("age",{1,2,3}) ==> where age not in(1,2,3) |
17 | inSql | 字段 in ( sql语句) | inSql("id","select id form user where age > 3") ==> id in(select id form user where age > 3) |
18 | notInSql | 字段 not in ( sql语句) | notInSql("id","select id form user where age > 3") ==> idnot in(select id form user where age > 3) |
19 | groupBy | 分组:group by | groupBy("id","name") ==> group by id,name |
20 | orderByAsc | 排序 :order by 正序 | orderByAsc("id","name") ==> order by id ASC,name ASC |
21 | orderByDesc | 排序 :order by 倒序 | orderByDesc("id","name") ==> order by id DESC,name DESC |
22 | orderBy | 排序:order by | orderBy("id","name") ==> order by id ASC,name ASC |
23 | having | having(sql语句) | having("sum{age} > {0}",11) ==> having sum(age) > 11 |
24 | or | 拼接 or | 注意事项:主动调用or表示紧接着下一个方法不是用and连接!(不调用or则用and连接)eq("id",1).or().eq("name","二狗子") ==> id = 1 or name = \'二狗子\' |
25 | and | and嵌套 | and(mapper.eq("id",1).ne("status",”活着“))==> id = 1 and status < > \'活着\' |
26 | apply | 拼接sql | 注意事项:该方法可用于数据库函数。动态入参的params对应前面sqlHaving{index}部分。这样是不会有sql注入风险的,反之则会有! apply("date_format(dateColumn,\'%Y-%m-%d\') = {0}","2020-10-24") ==> date_format(dateColumn,\'%Y-%m-%d\') = \'2020-10-24\'; |
27 | last | 无视优化规则直接拼接到sql的最后 | 注意事项:只能调用一次,多次调用以最后一次为准。有sql注入风险,需要谨慎使用。last("limit 1"); |
28 | exists | 拼接 exists(sql语句) | exists("select id from user where age = 1") ==> exists(select id from user where age = 1); |
29 | notExists | 拼接 not exists(sql语句) | notExists("select id from user where age = 1") ==> not exists(select id from user where age = 1); |
30 | nested | 正常嵌套,不带and或or | nested(mapper.eq("id",1).ne("status",”活着“)) ==> (id = 1 and status < > \'活着\') |
文章图片
来自为知笔记(Wiz)
推荐阅读
- Android_home配置环境变量
- Android Layout属性
- android-7
- Qt 解决(QWidget: Must construct a QApplication before a QWidget)
- 移动app快速开发的几点经验
- 微信小程序接口测试时appid为空如何解决
- node express框架 安装 app路由 正则路由 冒号引导变量 router级路由
- 第七章重排序与happens-before
- cordova混合App开发(Cordova+Vue实现Android APP开发 (打包及调试))