mybatisplus or查询
时间: 2023-09-21 13:11:57 浏览: 49
MyBatis Plus supports OR queries through its QueryWrapper class. You can use the or() method to add OR conditions to your query. Here's an example:
```java
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("age", 25)
.or()
.eq("gender", "female");
List<User> users = userMapper.selectList(queryWrapper);
```
In this example, the query will fetch users with an age of 25 OR users with a gender of "female". The or() method separates the two conditions and adds them as OR conditions in the generated SQL query.
You can also chain multiple OR conditions using the or() method. For instance:
```java
queryWrapper.eq("age", 25)
.or()
.eq("gender", "female")
.or()
.eq("city", "New York");
```
This query will fetch users with an age of 25, gender as "female", or city as "New York".
Remember to adjust the entity and column names according to your specific database schema.