聚合函數查詢
可以使用以下方法
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是個集合