lambdaQueryWrapper常用方法

例子

eq

等于

eq(“name”,“张三”) ------> name = ‘张三’

ne

不等于

ne(“name”,“张三”) ------> name <> ‘张三’

gt

大于

gt(“age”,18) ------> age > 18

ge

大于等于

ge(“age”,18) ------> age >= 18

lt

小于

lt(“age”,18) ------> age < 18

le

小于等于

le(“age”,18) ------> age <= 18

between

BETWEEN 值1 AND 值2

between(“age”,18,20) ------> age between 18 and 20

notBetween

NOT BETWEEN 值1 AND 值2

notBetween(“age”,18,20) ------> age not between 18 and 20

like

LIKE ‘%值%’

like(“name”,“张三”) ------> name like ‘%张三%’

notLike

NOT LIKE ‘%值%’

notLike(“name”,“张三”) ------> name not like ‘%张三%’

likeLeft

LIKE ‘%值’

likeLeft(“name”,“张三”) ------> name like ‘%张三’

likeRight

LIKE ‘值%’

likeRight(“name”,“张三”) ------> name like ‘张三%’

isNull

字段 IS NULL

isNull(“name”) ------> name is null

isNotNull

字段 IS NOT NULL

isNotNull(“name”) ------> name is not null

in

字段 IN (v0,v1,…)

in(“age”,{18,20,30}) ------> age in (18,20,30)

notIn

字段 NOT IN (v0,v1,…)

notIn(“age”,18,20,30) ------> age not in (18,20,30)

inSql

字段 IN (sql语句)

inSql(“id”,“select id from table where id < 3”) ------> id in (select id from table where id < 3)

notInSql

字段 NOT IN (sql语句)

notInSql(“id”,“select id from table where id < 3”) ------> id not in (select id from table where id < 3)

groupBy

分组: GROUP BY 字段,…

groupBy(“id”,“name”) ------> group by id,name

orderByAsc

排序:ORDERBY 字段,… ASC

orderByAsc(“id”,“name”) ------> order by id ASC,name ASC

orderByDesc

排序:ORDERBY 字段,… DESC

orderByDesc(“id”,“name”) ------> order by id DESC,name DESC

orderBy

排序:ORDERBY 字段,…

orderBy(“id”,“name”) ------> order by id DESC,name DESC

having

HAVING (slq语句)

having(“sum(age) > {0}”,11) ------>having sum(age) > 11

or

拼接 OR

注意事项: 主动调用or表示紧接着下一个方法不是用and连接!(不调用or则默认为使用and连接) eq(“id”,1).or().eq(“name”,“张三”) ------> id = 1 or name = ‘张三’

and

AND 嵌套

and(i -> i.eq(“name”,“张三”).ne(“age”,20) ------> and (name = ‘张三’ and age <> 20)

apply

拼接sql

注意事项:该方法可用于数据库函数 动态入参的params对应前面sqlHaving内部的{index}部分,这样是不会有sql注入风险的,反之会有!apply(“date_format(dateColumn,‘%Y-%m-%d’) = {0}”,“2022-02-08”) ------> date_format(dateColum, ‘%Y-%m-%d’) = ‘2022-02-08’

last

无视优化规则直接拼接到sql的最后

注意事项:只能调用一次,多次调用以最后一次为准,有sql注入的风险,请谨慎使用 last(“limt 2”)

exists

拼接EXISTS (sql语句)

exists(“select id from table where age = 20”) ------> exists (select id from table where age = 20)

notExists

拼接NOT EXISTS (sql语句)

notExists(“select id from table where age = 20”) ------> not exists (select id from table where age = 20)

nested

正常嵌套 不带AND 或者 OR

nested(i -> i.eq(“name”,“张三”).ne(“age”,20)) ------> nested(name = ‘张三’ and age <> 20)
————————————————
版权声明:本文为CSDN博主「普通网友」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/m0_67265464/article/details/126034440

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值