# mybatis多表多条件复合查询

编写UserMapper接口,继承tk.mybatis.mapper.common.Mapper接口

```java
public interface UserMapper extends Mapper<User> {
}  
```

在UserMapper接口方法中使用Example和PageHelper进行条件分页查询

```
java
PageHelper.startPage(page, size);
Example example = new Example(User.class);
Example.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(name)) {
    criteria.andLike("name", "%" + name + "%");
}
if (age != null) {
    criteria.andEqualTo("age", age);
}
List<User> list = mapper.selectByExampleAndResultMap(example, "UserResultMap");
PageInfo<User> pageInfo = new PageInfo<>(list);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://qiangrens-organization.gitbook.io/qkd90/shu-ju-ku-he-zhong-jian-jian/mybatis-duo-biao-duo-tiao-jian-fu-he-cha-xun.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
