Beginner

410. JOIN Duplicates

Understand why joins can produce duplicate-looking rows and how to investigate them.

📘 Lesson 410 of 728 ⏱ 12 min 🎯 Intermediate

Join duplicates occur when one row from one table matches multiple rows in another table, causing multiple result rows to be produced.

Unexpected duplicate rows can inflate totals, counts, and other analytical metrics and are a common SQL reporting problem.

A customer with five orders will produce five joined rows when the customer table is joined to the orders table.

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

Analysts investigate join duplication when reconciling reports, calculating sales totals, counting customers, and building dashboards.

  • Joins can legitimately create multiple rows.
  • One-to-many relationships commonly produce repeated parent information.
  • Duplicate-looking rows are not always actual duplicate source records.
  • Incorrect join conditions can create unexpected row multiplication.
  • Always validate row counts after important joins.
Why can a JOIN increase the number of rows?

If one row matches multiple rows in the other table, SQL returns a result row for each matching combination.

How can you investigate unexpected join duplicates?

Check table relationships, join conditions, key uniqueness, and row counts before and after the join.

Have you finished this lesson?

Introduction to SQL – All Lessons