Beginner

539. One-to-Many JOIN

Understand how one-to-many relationships affect JOIN results.

📘 Lesson 539 of 728 ⏱ 12 min 🎯 Intermediate

A one-to-many relationship occurs when one row in a parent table can be associated with multiple rows in a child table.

One-to-many relationships are extremely common and are a major reason JOIN queries can return multiple rows for a single parent record.

One customer can place many orders.

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

Common in customer-order, department-employee, account-transaction, and product-sales systems.

  • One parent can have many child records.
  • JOIN results can contain multiple rows per parent.
  • Foreign keys commonly represent the child side.
  • Aggregations may be required after the JOIN.
  • Always understand relationship cardinality.
What is a one-to-many relationship?

It is a relationship where one record in a parent table can relate to multiple records in a child table.

Give a common one-to-many example.

One customer having multiple orders is a common one-to-many relationship.

Have you finished this lesson?

Introduction to SQL – All Lessons