Member-only story

Navigating Relationships: A Comprehensive Guide to 9 Database Joins

btd
7 min readNov 9, 2023

--

A join is an operation that combines rows from two or more tables based on a related column between them. The primary purpose of using joins is to retrieve and consolidate information from multiple tables, enabling more complex and meaningful analyses.

1. Inner Join

  • An inner join returns only the rows that have matching values in both data sets being joined. Rows that do not have matching values in both data sets are excluded from the result.
  • This type of join is useful for combining data based on a common key or identifier.
  • It helps filter out data that does not have corresponding values in both sets, focusing on the intersection of the data.
Table: Orders
+--------+------------+-------+
| OrderID| CustomerID | Total |
+--------+------------+-------+
| 1 | 101 | 100 |
| 2 | 102 | 150 |
| 3 | 103 | 200 |
+--------+------------+-------+

Table: Customers
+------------+----------+
| CustomerID | Name |
+------------+----------+
| 101 | Alice |
| 102 | Bob |
| 104 | Charlie |
+------------+----------+

Resultant Table After Inner Join
+--------+------------+-------+----------+
| OrderID| CustomerID | Total | Name |…

--

--

btd
btd

No responses yet