LambdaQueryWrapper distinct
时间: 2023-10-14 21:03:58 浏览: 115
LambdaQueryWrapper的distinct方法可以用于去除查询结果中的重复元素。在使用LambdaQueryWrapper进行查询时,可以使用.distinct()方法来实现这个功能。例如,可以按照以下方式使用.distinct()方法来实现去除查询结果中的重复元素:
```java
QueryWrapper<Student> queryWrapper = new QueryWrapper<>();
queryWrapper.select("name").distinct(true);
List<Student> students = studentMapper.selectList(queryWrapper);
```
以上代码会查询出所有学生的姓名,并且去除重复的姓名。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [MybatisPlus lambdaQueryWrapper中常用方法](https://blog.csdn.net/moyingmj/article/details/121796354)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [Lambda中间操作distinct](https://blog.csdn.net/Leon_Jinhai_Sun/article/details/125232870)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文