Data engineering and IT

Join

  • Data engineering and IT

Definition

Combining rows from two tables into one result by matching values in a related column, such as a customer ID.

Example

Raket Parts B.V. stores 7,235 sales orders and 436 customers in separate tables. Joining sales_orders to customers on customer_ref adds each customer's segment and country to its orders. Every order has a matching customer, so the result has 7,235 rows.

Raket Parts B.V. is a fictional company created for Insyt.

See how it works

SELECT o.so_ref, o.order_date, c.segment
FROM sales_orders AS o
JOIN customers AS c
  ON c.customer_ref = o.customer_ref;

Each order comes back with its customer's segment.

Check your understanding

Common mistake: If the joined key is not unique on the intended side, rows may multiply and inflate totals.

Why check how many rows each key can match?

Show explanation

The relationship determines whether a join preserves, duplicates or removes rows.

For your role

Choose your role to see what this term means in your work.

Why it matters

Most useful questions need data from more than one table, and the wrong join silently drops or duplicates rows.

Where it is used

SQL queries, data models and BI reports. Used by data analysts, BI developers, data engineers and anyone writing SQL.