Beginner

584. One-to-Many JOIN

Understand the most common JOIN relationship where one record is related to many records.

📘 Lesson 584 of 728 ⏱ 12 min 🎯 Intermediate

A one-to-many relationship occurs when one row in a parent table can have multiple related rows in a child table, such as one customer having many orders.

Most transactional databases use one-to-many relationships, and they directly affect JOIN results and aggregations.

Join each customer to all orders placed by that customer.

SQL
SELECT
    c.CustomerName,
    o.OrderID,
    o.OrderAmount
FROM Customers c
INNER JOIN Orders o
    ON c.CustomerID = o.CustomerID;

Used in sales, banking, HR, inventory, customer, and transaction systems.

  • One parent can have many child records.
  • JOIN results may contain repeated parent values.
  • Aggregation is often used for summaries.
  • Foreign keys commonly represent the relationship.
  • Cardinality should be considered before calculating totals.
What is a one-to-many relationship?

It occurs when one row in a parent table can be associated with multiple rows in a child table.

What happens when a one-to-many relationship is JOINed?

The parent row can appear once for each matching child record.

Have you finished this lesson?

Introduction to SQL – All Lessons