MySQL Joins

Joining tables.

MySQL Joins

A JOIN clause is used to combine rows from two or more tables, based on a related column between them.

Types of SQL Joins

  • INNER JOIN: Returns records that have matching values in both tables
  • LEFT JOIN: Returns all records from the left table, and the matched records from the right table
  • RIGHT JOIN: Returns all records from the right table, and the matched records from the left table
  • CROSS JOIN: Returns all records from both tables (Cartesian product)

Example

SELECT * FROM Orders JOIN Customers ON Orders.CustomerID = Customers.CustomerID;