Skip to content
Interactive SQL reference

See exactly which rows a SQL join keeps.

Switch between four join types. Watch unmatched customers and orders enter or leave the result—and notice why one customer can appear more than once.

Join type
customers
customer_idcustomer_name
1Ada
2Bo
3Cy
orders
order_idcustomer_id
1011
1021
1032
1044
SQLMatch on customer_id
SELECT
  COALESCE(c.customer_id, o.customer_id) AS customer_id,
  c.customer_name,
  o.order_id
FROM customers AS c
INNER JOIN orders AS o
  ON c.customer_id = o.customer_id
ORDER BY customer_id, order_id;
Result3 rows
customer_idcustomer_nameorder_id
1Ada101
1Ada102
2Bo103

Matches can multiply rows

Ada has two orders, so the matching customer row appears twice. A join does not preserve the left table’s row count automatically.

NULL marks the missing side

Outer joins retain unmatched records. Columns from the side without a match become NULL.

Dialect support varies

RIGHT and FULL OUTER JOIN syntax is not available in every engine or version. Check your warehouse documentation.

Continue learning

Learn the patterns, then run the query.

The full guide explains join selection, multi-table joins, duplicate rows, and common mistakes. Practice applies those ideas in the browser.