有关mybatis-plus queryWrapper、updateWrapper(1)

最近,同事新增一个项目使用springboot+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
notBetweenNot  between  *  and  *例:notBetween("age",10,20)---> age not between 10 and 20
likelike '%XX%'例:like("name","徐") ---> name like "%徐%"
notLikeNot like '%XX%'例:notLike("name","徐") ---> name not like "%徐%"
likeLeftlike '%XX%'例:likeLeft("name","徐") ---> name like "%徐"
likeRightlike '%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
havingHAVING(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"

   
   

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值