# mybatis-plus-join
**Repository Path**: yulichang/mybatis-plus-join
## Basic Information
- **Project Name**: mybatis-plus-join
- **Description**: 支持连表查询的mybatis-plus体验!mybatis-plus风格的连表操作,提供
leftJoin、rightJoin、innerJoin连表操作
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: https://mybatis-plus-join.github.io
- **GVP Project**: No
## Statistics
- **Stars**: 1834
- **Forks**: 327
- **Created**: 2021-01-27
- **Last Updated**: 2026-08-30
## Categories & Tags
**Categories**: database-dev
**Tags**: MyBatis, MybatisPlus, SQL, 低代码, JDBC
## README
MyBatis-Plus-Join
为简化开发工作、提高生产率而生
对 MyBatis-Plus 多表查询的扩展 |
演示工程 |
使用文档 |
点个Star支持一下吧 (☆▽☆)
可添加作者微信,咨询问题或提供意见与建议
### 使用文档WIKI
## 使用方法
### 安装
- Maven
```xml
com.github.yulichang
mybatis-plus-join-boot-starter
1.5.9
```
- Gradle
```
implementation 'com.github.yulichang:mybatis-plus-join-boot-starter:1.5.9'
```
或者clone代码到本地执行 `mvn install`, 再引入以上依赖
### 版本对应关系:
| Mybatis-Plus-Join | Mybatis-Plus |
|-------------------|----------------|
| 1.5.9 | 3.5.17+ |
| 1.5.8 | 3.1.2 - 3.5.16 |
### 使用
* mapper继承MPJBaseMapper
### Lambda形式用法(MPJLambdaWrapper)
#### 简单的连表查询
```java
class test {
@Resource
private UserMapper userMapper;
void testJoin() {
MPJLambdaWrapper wrapper = JoinWrappers.lambda(UserDO.class)
.selectAll(UserDO.class)
.select(AddressDO::getTel)
.leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId)
.eq(UserDO::getId, 1)
.like(AddressDO::getTel, "1");
//连表查询 返回自定义ResultType
List list = userMapper.selectJoinList(UserDTO.class, wrapper);
//分页查询 (需要启用 mybatis plus 分页插件)
Page listPage = userMapper.selectJoinPage(new Page<>(2, 10), UserDTO.class, wrapper);
}
}
```
对应sql
```
SELECT
t.id, t.name, t.sex, t.head_img,
t1.tel
FROM user t
LEFT JOIN address t1 ON t1.user_id = t.id
WHERE ( t.id = ? AND t1.tel LIKE ? )
```
# 完整使用文档 wiki
# 用爱发电