mybatisplus between
时间: 2023-08-14 21:13:37 浏览: 130
mybatis-plus
MyBatis-Plus provides a convenient way to perform range queries using the `between` method. The `between` method is available on the `QueryWrapper` class, which is used to build dynamic queries.
Here's an example of how to use the `between` method in MyBatis-Plus:
```java
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.between("age", 20, 30);
List<User> userList = userDao.selectList(queryWrapper);
```
In this example, we create a `QueryWrapper` object and call the `between` method on it. We pass in the column name ("age" in this case) and the range values (20 and 30) as parameters. This will generate a SQL query that includes a `BETWEEN` condition for the specified column.
The resulting `QueryWrapper` is then passed to the `selectList` method of the user's DAO (Data Access Object) to retrieve a list of users whose age is between 20 and 30.
Note that the `between` method can also be used with other comparison operators, such as `>=` and `<=`. Additionally, you can chain multiple `between` conditions together or combine them with other query conditions using the various methods provided by MyBatis-Plus.
阅读全文