Mybatis-plus链式调用方法QueryWrapper的整理

177 阅读1分钟
查询方法说明
eq等于=
ne不等于<>
gt大于>
ge大于等于>=
lt小于<
le小于等于<=
betweenBETWEEN 值1 AND 值2
notBetweenNOT BETWEEN 值1 AND 值2
likeLIKE '%值%'
notLikeNOT LIKE '%值%'
inIN (值1,值2...)
notInNOT IN (值1,值2...)
isNull字段 IS NULL
isNotNull字段 IS NOT NULL
allEq所有等于查询
orOR条件查询
orderByAsc升序排序
orderByDesc降序排序

希望在SQL语句中的添加括号

where name = 'xxx' and section = 12 or dept = 5

这里实际希望的语句是

where name = 'xxx' and (section = 12 or dept = 5)

在 QueryWrapper 中可以用 and 来处理

QueryWrapper<Member> q = new QueryWrapper<>();
q.eq("name", "xxx");
q.and(e-> e.eq("section",12)
    .or().eq("dept",5));