mybatisplus查询list集合
时间: 2023-08-30 17:04:59 浏览: 244
mybatis联合查询
在使用Mybatis-plus查询表中某个字段的值并返回List集合时,可以使用selectBatchIds方法。该方法可以根据主键的id集合进行多条数据的查询,并返回一个List集合。具体的代码示例如下:
```java
List<Integer> idList = Arrays.asList(1, 2);
List<User> userList = userMapper.selectBatchIds(idList);
```
以上代码会查询出id为1和2的两条记录,并将其封装成一个List集合返回。你可以根据需要将User替换为你的实体类名。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [使用Mybatis-plus,查询表中某个字段的值,返回List集合](https://blog.csdn.net/cc920095705/article/details/109076444)[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_1"}}] [.reference_item style="max-width: 50%"]
- *2* [Mybatis-Plus常用的查询方法--看这一篇就够了!!!](https://blog.csdn.net/qq_52423918/article/details/119455043)[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_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文