Skip to content

Commit 067688d

Browse files
Update 05 - Inner Join.md
1 parent f677acb commit 067688d

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Database Articles/Advanced SQL Joins/05 - Inner Join.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
---------------------------------------------------------------------------------
88

9-
We will be using the following tables that contain types of fruits and their quantity.
9+
We will use the following tables that contain types of fruits and their quantity.
1010

1111
[The DDL to create these tables can be found here.](Sample%20Data.md)
1212

@@ -121,9 +121,9 @@ WHERE b.Fruit = 'Apple'
121121

122122
---------------------------------------------------------------------------------
123123

124-
This following statement incorporates an `INNER JOIN` with a theta-join, which looks for inequality between two fields.
124+
This following statement incorporates an `INNER JOIN` with a non-equi-join.
125125

126-
An excellent example of using a theta-join is when someone wants to pair two different fruits of different quantities.
126+
An excellent example of using a non-equi-join is when someone wants to pair two different fruits of different quantities.
127127

128128
```sql
129129
SELECT a.ID,
@@ -138,7 +138,7 @@ FROM ##TableA a INNER JOIN
138138

139139
---------------------------------------------------------------------------------
140140

141-
This query uses an equi-join and a theta-join and functions similar to a `CROSS JOIN`, but with one big difference, NULL markers are not returned. NULL markers are neither equal to nor not equal to each other. They are unknown.
141+
This query uses an equi-join and a non-equi-join and functions similar to a `CROSS JOIN`, but with one big difference, NULL markers are not returned. NULL markers are neither equal to nor not equal to each other. They are unknown.
142142

143143
```sql
144144
SELECT a.ID,
@@ -163,7 +163,7 @@ FROM ##TableA a INNER JOIN
163163

164164
---------------------------------------------------------------------------------
165165

166-
Here are some other examples of `INNER JOINS` using theta-joins.
166+
Here are some other examples of `INNER JOINS` using non-equi-joins.
167167

168168
This query looks for all values where the quantity in `TableA` is greater than or equal to a quantity in the corresponding `TableB`.
169169

@@ -181,7 +181,7 @@ FROM ##TableA a INNER JOIN
181181

182182
---------------------------------------------------------------------------------
183183

184-
This query uses an equi-join and a theta-join negated with a `NOT` operator. Determining if the `ID` is between the `Quantity` columns may be a somewhat absurd SQL statement to write, but this shows the possibilities in creating join logic. We often forget we can use comparison operators such as `LIKE` or `BETWEEN` in an SQL statement's `ON` clause and then negate it with `NOT`.
184+
This query uses an equi-join and a non-equi-join negated with a `NOT` operator. Determining if the `ID` is between the `Quantity` columns may be an absurd SQL statement to write, but this shows the possibilities in creating join logic. We often forget we can use comparison operators such as `LIKE` or `BETWEEN` in an SQL statement's `ON` clause and then negate it with `NOT`.
185185

186186
```sql
187187
SELECT a.ID,
@@ -199,7 +199,7 @@ FROM ##TableA a INNER JOIN
199199
| 4 | \<NULL> | 5 | 4 | \<NULL> | \<NULL> |
200200

201201
---
202-
Functions can be used in the join condition as well. Assigning the empty string to a NULL value via the `ISNULL` function causes the NULLs to now equate to each other.
202+
Functions can also be used in the join condition. Assigning the empty string to a NULL value via the `ISNULL` function causes the NULLs to equate to each other.
203203

204204
```sql
205205
SELECT a.ID,
@@ -253,7 +253,7 @@ WHERE (CASE WHEN a.Fruit = 'Apple' THEN a.Fruit ELSE 'Peach' END) = b.Fruit;
253253
| 4 | \<NULL> | 2 | Peach |
254254
255255
---------------------------------------------------------------------------------
256-
When joining three or more statements, this SQL statement works in `SQL Server`. The table referenced in the `ON` clause must be in reverse order for this to work.
256+
This SQL statement works in `SQL Server` when joining three or more statements. The table referenced in the `ON` clause must be in reverse order for this to work.
257257

258258
For this SQL statement, I am self-joining to `TableA` three times.
259259

0 commit comments

Comments
 (0)