函数 | 说明 | 例子 |
---|---|---|
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, 30) -> age between 18 and 30 |
notBetween | NOT BETWEEN 值1 AND 值2 | notBetween("age", 18, 30) -> age not between 18 and 30 |
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 (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 字段,… ASC | orderByAsc("id", "name") -> order by id ASC, name ASC |
orderByDesc | 排序: ORGER BY 字段,… DESC | orderByDesc("id", "name") -> order by id DESC, name DESC |
orderBy | 排序: ORDER BY 字段,… | orderBy(true, true, "id", "name") -> order by id ASC, name ASC |
having | HAVING (SQL语句) | having("sum(age) > {0}", 11) -> having sum(age) > 11 |
or | 拼接 | eq("id", 1).or().eq("name", "张三") -> id=1 OR name='张三' , 如果不掉用,默认是AND连接 |
and | AND 嵌套 | 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或者OR | nested(i -> id.eq("name", "张三").ne("status", "1")) -> (name = '张三' AND status <> '1') |
MySQL-Plus QueryWrapper函数与SQL语句对比表
最新推荐文章于 2024-07-26 15:20:49 发布