LearnSQL TutorialJoining Tables

Joining Tables

1 min read

JOIN

A JOIN combines rows from two tables based on a related column.

SELECT orders.id, users.name
FROM orders
INNER JOIN users ON orders.user_id = users.id;

Types of joins

  • INNER JOIN — only matching rows in both tables
  • LEFT JOIN — all rows from the left table, matched where possible
  • RIGHT JOIN — all rows from the right table