mirror of
https://github.com/treffynnon/sqlstyle.guide.git
synced 2025-03-09 12:49:51 -05:00
JOINs
This commit is contained in:
parent
fb6eac76ed
commit
3603d371de
1 changed files with 9 additions and 12 deletions
|
@ -88,7 +88,7 @@ FROM staff;
|
|||
```sql
|
||||
SELECT first_name AS fn
|
||||
FROM staff AS s1
|
||||
JOIN students AS s2
|
||||
JOIN students AS s2
|
||||
ON s2.mentor_id = s1.staff_num;
|
||||
```
|
||||
```sql
|
||||
|
@ -220,8 +220,7 @@ This allows the reader to quickly scan for the important building blocks of the
|
|||
|
||||
#### Joins
|
||||
|
||||
Joins should be indented to the other side of the river and grouped with a new
|
||||
line where necessary.
|
||||
Joins should be indented 2 spaces right from the `FROM` keyword
|
||||
|
||||
Single line `JOIN`s are fine for simple situations
|
||||
|
||||
|
@ -250,9 +249,7 @@ Indent them until the closing parentheses.
|
|||
WITH my_tmp_table AS (
|
||||
SELECT r.last_name
|
||||
FROM riders AS r
|
||||
INNER JOIN bikes b
|
||||
ON r.bike_vin_num = b.vin_num
|
||||
AND r.bike_lane = r.lane
|
||||
INNER JOIN bikes b ON r.bike_vin_num = b.vin_num
|
||||
)
|
||||
|
||||
SELECT *
|
||||
|
|
Loading…
Reference in a new issue