条件构造器之AbstractWrapper实例

官方文档:https://mp.baomidou.com/guide/wrapper.html#abstractwrapper

总觉得直接看例子比看规则语句更快的理解和记忆,特此整合如下(分段纯属为了好对比)

  • allEq({id:1,name:"老王",age:null})---> where id = 1 and name = '老王' and age is null
  • allEq({id:1,name:"老王",age:null}, false)--->id = 1 and name = '老王'//忽略value为null的值
  • eq("name", "老王")---> where name = '老王'
  • ne("name", "老王")--->where name <> '老王'
  • gt("age", 18)---> where age > 18

  where...

  • ge("age", 18)--->age >= 18
  • lt("age", 18)--->age < 18
  • le("age", 18)--->age <= 18
  • between("age", 18, 30)--->age between 18 and 30
  • notBetween("age", 18, 30)--->age not between 18 and 30

 

  • like("name", "王")--->name like '%王%'
  • notLike("name", "王")--->name not like '%王%'
  • likeLeft("name", "王")--->name like '%王'
  • likeRight("name", "王")--->name like '王%'
  • isNull("name")--->name is null
  • isNotNull("name")--->name is not null

 

  • in("age",{1,2,3})--->age in (1,2,3)
  • in("age", 1, 2, 3)--->age in (1,2,3)
  • notIn("age",{1,2,3})--->age not in (1,2,3)
  • notIn("age", 1, 2, 3)--->age not in (1,2,3)
  • inSql("age", "1,2,3,4,5,6")--->age in (1,2,3,4,5,6)
  • inSql("id", "select id from table where id < 3")--->id in (select id from table where id < 3)
  • notInSql("age", "1,2,3,4,5,6")--->age not in (1,2,3,4,5,6)

 

  • groupBy("id", "name")--->group by id,name
  • orderByAsc("id", "name")--->order by id ASC,name ASC
  • orderByDesc("id", "name")--->order by id DESC,name DESC
  • orderBy(true, true, "id", "name")--->order by id ASC,name ASC
  • having("sum(age) > 10")--->having sum(age) > 10
  •  
  • eq("id",1).or().eq("name","老王")--->id = 1 or name = '老王'
  • or(i -> i.eq("name", "李白").ne("status", "活着"))--->or (name = '李白' and status <> '活着')
  • and(i -> i.eq("name", "李白").ne("status", "活着"))--->and (name = '李白' and status <> '活着')
  • nested(i -> i.eq("name", "李白").ne("status", "活着"))--->(name = '李白' and status <> '活着')
  •  
  • apply("id = 1")--->id = 1
  • apply("date_format(dateColumn,'%Y-%m-%d') = '2008-08-08'")--->date_format(dateColumn,'%Y-%m-%d') = '2008-08-08'")
  • apply("date_format(dateColumn,'%Y-%m-%d') = {0}", "2008-08-08")--->date_format(dateColumn,'%Y-%m-%d') = '2008-08-08'"
  •  
  • last("limit 1")
  • exists("select id from table where age = 1")--->exists (select id from table where age = 1)
  • notExists("select id from table where age = 1")--->not exists (select id from table where age = 1)
  •  
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值