Join

A join is an operation in SQL that combines rows from two or more tables based on a related column.

Explanation:

Joins allow fetching related data across tables. The most common types include:

  1. INNER JOIN โ€“ Returns matching rows from both tables.
  2. LEFT JOIN โ€“ Returns all rows from the left table and matching rows from the right.
  3. RIGHT JOIN โ€“ Returns all rows from the right table and matching rows from the left.
  4. FULL JOIN โ€“ Returns all rows from both tables.

Example INNER JOIN:

sqlCopyEditSELECT Employees.name, Departments.department_name
FROM Employees
INNER JOIN Departments ON Employees.department_id = Departments.department_id;