最近,同事新增一个项目使用springboot+mybatis-plus的使用,对于queryWrapper,updateWrapper这一系列的构造器有些迷糊,为了更好的说明使用的方式 我在这篇博客中简单简述一下。

1.构造器的关系

有关mybatis-plus queryWrapper、updateWrapper(1)

 2.函数相关说明

函数名 说明 例子
eq 等于== 例:eq("age",10)---> age = 10
ne 不等于 <> 例:ne("age",10)---> age <> 10
gt 大于 > 例:gt("age",10)---> age > 10
ge 大于等于  >= 例:ge("age",10)---> age >= 10
lt 小于 < 例:lt("age",10)---> age < 10
le 小于等于 <= 例:le("age",10)---> age < = 10
between  between  *  and  * 例:between("age",10,20)---> age between 10 and 20
notBetween Not  between  *  and  * 例:notBetween("age",10,20)---> age not between 10 and 20
like like '%XX%' 例:like("name","徐") ---> name like "%徐%"
notLike Not like '%XX%' 例:notLike("name","徐") ---> name not like "%徐%"
likeLeft like '%XX%' 例:likeLeft("name","徐") ---> name like "%徐"
likeRight like '%XX%' 例:likeRight("name","徐") ---> name like "徐%"
isNull 字段 is null 例:isNull("name") --->name  is null
isNotNull 字段 is  not null 例:isNotNull("name") --->name  is not  null
in 字段 in (XX,xx,x) 例:in ("age",{1,2,3})---> age in (1,2,3)
notIn 字段  not in (XX,xx,x) 例:notIn("age",{1,2,3})---> age not  in (1,2,3)
inSql 字段  in (sql 语句)

例:inSql("id", select id from student where id <3 ) --->

id in ( select id from student where id <3)

notInSql 字段 not in (sql 语句) 例:notInSql("id", select id from student where id <3 ) --->

id not in ( select id from student where id <3)

groupBy 分组:group by 例:groupBy("id","name") --->group By id ,name
orderByAsc 排序:order by 字段 ,.. Asc 例:orderByAsc("id","name") --->order By id ,name    Asc
orderByDesc 排序:order by 字段 ,.. desc 例:orderByDesc("id","name") --->order By id ,name    desc
orderBy 排序:order by 字段 ,.. 例:orderBy(true,true,"id","name") --->order By id asc , name    sc
having HAVING(sql 语句) 例:having("sum(age) > {0}",11) ---> -having sum(age) > 11
or 拼接 or

例:

eq("age",10).or.eq("age",11) ---> age= 10  or age = 11

 

and  and 嵌套 例:
last 无视优化规则直接拼接到 sql 最后 例:
exists 拼接 exists (sql 语句) 例:
notexists 拼接 not exists (sql 语句) 例:
nested 正常嵌套 不带 and  或者 or 例:
apply 拼接 sql

例:apply("date_format(create_time,'%Y-%m-%d')={0}, "2020-01-17")--------->

date_format(create_time,'%Y-%m-%d')="2020-01-17"

     
     

 

相关文章:

  • 2021-10-23
  • 2021-09-21
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
猜你喜欢
  • 2021-07-19
  • 2022-12-23
  • 2021-05-07
相关资源
相似解决方案