mybatis plus count
时间: 2023-08-27 12:15:00 浏览: 114
Mybatis plus中使用count聚合函数的方式有多种。可以直接在QueryWrapper的select方法中指定count(*)作为查询字段,例如:lqw.select("count(*) as count")。这样就可以得到count的结果。 另外,也可以直接调用.select方法,并传入"COUNT(*) as count"作为参数,例如:csArchiveQueryWrapper.select("COUNT(*) as count")。这样也可以得到count的结果。 如果需要实现分组查询,可以在QueryWrapper中指定groupBy字段,并在select中同时指定要查询的字段和聚合函数,例如:lqw.select("count(*) as count,tel"),然后调用groupBy("tel")方法进行分组。这样就可以实现分组查询并得到对应的结果。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [MyBatisPlus-聚合查询、分组查询及等值查询](https://blog.csdn.net/m0_61961937/article/details/125955560)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [MybatisPlus调用count函数](https://blog.csdn.net/qq_43072106/article/details/122090405)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文