MyBatis Plus Fuzzy Query Guide

In MyBatis Plus, fuzzy querying can be achieved by building a QueryWrapper object. Here is an example code:

// 创建QueryWrapper对象
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
// 使用like方法进行模糊查询,第一个参数为字段名,第二个参数为要匹配的值
queryWrapper.like("username", "张");

// 调用selectList方法进行查询
List<User> userList = userMapper.selectList(queryWrapper);

In the example above, we first create a QueryWrapper object, then use the like method for performing a fuzzy search, and finally call the selectList method to execute the query operation. This allows us to perform a fuzzy search on data in the username field containing the character “Zhang”.

bannerAds