MySQL-Plus QueryWrapper函数与SQL语句对比表

函数说明例子
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
betweenBETWEEN 值1 AND 值2between("age", 18, 30) -> age between 18 and 30
notBetweenNOT BETWEEN 值1 AND 值2notBetween("age", 18, 30) -> age not between 18 and 30
likeLIKE ‘%值%’like("name", "王") -> name like '%王%'
notLikeNOT LIKE ‘%值%’notLike("name", "王") -> name not like '%王%'
likeLeftLIKE ‘%值’likeLeft("name", "王") -> name like '%王'
likeRightLIKE ‘值%’likeRight("name", "王") -> name like '王%'
isNull字段 IS NULLisNull("name") -> name is null
isNotNull字段 IS NOT NULLisNotNull("name") -> name is not null
in字段 IN (v1,v2,…)in("age", {1,2,3}) -> age in (1,2,3)
notIn字段 NOT IN (v1,v2,…)notIn("age", {1,2,3}) -> age not in (1,2,3)
inSql字段 IN (SQL语句)inSql("id", "select id from table where id < 10") -> age in (select id from table where id < 10)
notInSql字段 NOT IN (SQL语句)notInSql("id", "select id from table where id < 10") -> age not in (select id from table where id < 10)
groupBy分组: GROUP BY 字段,…groupBy("id", "name") -> group by id,name
orderByAsc排序: ORGER BY 字段,… ASCorderByAsc("id", "name") -> order by id ASC, name ASC
orderByDesc排序: ORGER BY 字段,… DESCorderByDesc("id", "name") -> order by id DESC, name DESC
orderBy排序: ORDER BY 字段,…orderBy(true, true, "id", "name") -> order by id ASC, name ASC
havingHAVING (SQL语句)having("sum(age) > {0}", 11) -> having sum(age) > 11
or拼接eq("id", 1).or().eq("name", "张三") -> id=1 OR name='张三', 如果不掉用,默认是AND连接
andAND 嵌套and(i -> i.eq("name", "张三").ne("status", "1")) -> AND (name='张三' AND status <> '1')
apply拼接 SQL该方法可用于数据库函数,apply("date_format(dataColumn, '%Y-%m-%d') = {0}", "2008-08-08") -> date_format(dateColumn, '%Y-%m-%d') = '2008-08-08'
last不进行SQL优化只能调用一次,多次调用最后一次为准,无视优化规则直接拼接到SQL最后,有SQL注入风险,last("limit", 1)
exists拼接 EXISTS (SQL语句)exists("select id frome table where age = 1") -> exists (select id from table where age = 1)
notExists拼接 NOT EXISTS (SQL语句)notExists("select id frome table where age = 1") -> not exists (select id from table where age = 1)
nested正常嵌套不带AND或者ORnested(i -> id.eq("name", "张三").ne("status", "1")) -> (name = '张三' AND status <> '1')
  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值