mybatisplus lambda distinct
时间: 2023-09-17 21:14:58 浏览: 57
To use the distinct keyword in MyBatis Plus with lambda expressions, you can use the following code:
```
LambdaQueryWrapper<Entity> wrapper = Wrappers.lambdaQuery();
wrapper.select(Entity::getColumn1, Entity::getColumn2)
.distinct(true)
.eq(Entity::getColumn3, value);
List<Entity> list = entityMapper.selectList(wrapper);
```
In this example, we create a LambdaQueryWrapper and specify the columns to select using the `select()` method with lambda expressions. We then set the `distinct` flag to true using the `distinct()` method and add any additional query conditions using the various `eq()`, `like()`, or other methods available.
Finally, we execute the query using the `selectList()` method of the entity mapper, which returns a list of entities with distinct values for the specified columns.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)