【MyBatis-plus】条件构造器详解(1)

本文详细介绍了MyBatis-Plus的条件构造器,包括`in`、`notIn`、`groupBy`、`orderBy`、`having`等方法的使用,并提供了丰富的示例,展示了如何在实际操作中构建复杂的SQL查询。此外,还提到了`lambda`和`kotlin`持久化对象定义的最佳实践,以及美团面试的相关经验。
摘要由CSDN通过智能技术生成

in("age",{1,2,3})—>age in (1,2,3)

in(R column, Object… values)

in(boolean condition, R column, Object… values)

字段 IN (v0, v1, …)

in("age", 1, 2, 3)—>age in (1,2,3)

notIn

notIn(R column, Collection<?> value)

notIn(boolean condition, R column, Collection<?> value)

  • 字段 NOT IN (value.get(0), value.get(1), …)

  • 例: notIn("age",{1,2,3})—>age not in (1,2,3)

notIn(R column, Object… values)

notIn(boolean condition, R column, Object… values)

  • 字段 NOT IN (v0, v1, …)

  • 例: notIn("age", 1, 2, 3)—>age not in (1,2,3)

inSql

inSql(R column, String inValue)

inSql(boolean condition, R column, String inValue)

  • 字段 IN ( sql语句 )

  • 例: 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

notInSql(R column, String inValue)

notInSql(boolean condition, R column, String inValue)

  • 字段 NOT IN ( sql语句 )

  • 例: notInSql("age", "1,2,3,4,5,6")—>age not in (1,2,3,4,5,6)

  • 例: notInSql("id", "select id from table where id < 3")—>id not in (select id from table where id < 3)

groupBy

groupBy(R… columns)

groupBy(boolean condition, R… columns)

  • 分组:GROUP BY 字段, …

  • 例: groupBy("id", "name")—>group by id,name

orderByAsc

排序:ORDER BY 字段, … ASC

orderByAsc(R… columns)

orderByAsc(boolean condition, R… columns)

实例

orderByAsc("id", "name")—>order by id ASC,name ASC

orderByDesc

orderByDesc(R

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值