forked from wangweianger/mysqls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77dda1a
commit 12ac6f7
Showing
9 changed files
with
140 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
join方法属于链式调用方法之一, 主要用于联表查询 | ||
|
||
|
||
### 案例 | ||
|
||
join参数为Array<object> 或 object类型, 例如: | ||
|
||
|
||
Array类型参数 | ||
```js | ||
sql.table('node_table').join([{ | ||
dir: 'left', | ||
table: ('left_table'), | ||
where: [{'node_talbe.id': ['join_table.id']}] | ||
}, { | ||
dir: 'right', | ||
table: ('right_table'), | ||
where: [{'right_table.id': ['left_table.id']}] | ||
}]).where('node_table.id=1').select() | ||
``` | ||
|
||
最终得到 | ||
```js | ||
SELECT * FROM node_table LEFT JOIN left_table ON ((node_talbe.id=join_table.id) ) RIGHT JOIN right_table ON ((right_table.id=left_table.id) ) WHERE node_table.id=1 | ||
``` | ||
|
||
object类型参数 | ||
```js | ||
sql.table('node_table').join({ | ||
dir: 'left', | ||
table: ('left_table'), | ||
where: [{'node_talbe.id': ['join_table.id']}] | ||
}).where('node_table.id=1').select() | ||
``` | ||
|
||
最终得到 | ||
```js | ||
SELECT * FROM node_table LEFT JOIN left_table ON ((node_talbe.id=join_table.id) ) WHERE node_table.id=1 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.