Mybatis-Plus中使用max、sum聚合函数、只查询指定字段、查询语句多个OR处理

聚合函数查询

可以使用以下方法

  QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.select("  IFNULL( max(percent),0) as maxPercent");
        Map<String, Integer> map = getMap(queryWrapper);
        return map.get("maxPercent");

只查询指定字段(只查询三个字段)

 queryWrapper.select("content_id","img_url","title")

排除某些字段 这表示不查询Content实体类对应的数据库中的content_txt字段

queryWrapper.select(
                Content.class, info ->
                        !info.getColumn().equals("content_txt")
        )

and后面跟多个or(and (or or or ))

queryWrapper.eq("id", "1");
            queryWrapper.and(wrapper -> {
                searchTitle.forEach(s -> {
                    wrapper.or().like("title", s);
                });
            });

等价 where id=1 and ( title like '%s%' or titile like '%s%');  这里的searchTitle是个集合 

-----------------------有任何问题可以在评论区评论,也可以私信我,我看到的话会进行回复,欢迎大家指教------------------------ (蓝奏云官网有些地址失效了,需要把请求地址lanzous改成lanzoux才可以)
原文地址:https://www.cnblogs.com/pxblog/p/15367161.html