Explain different types of JOIN operations.

Beginner

Answer

  • INNER JOIN: Returns records matching in both tables
  • LEFT JOIN: Returns all records from left table and matching from right
  • RIGHT JOIN: Returns all records from right table and matching from left
  • FULL OUTER JOIN: Returns all records from both tables
  • CROSS JOIN: Returns Cartesian product of both tables

Example:

-- INNER JOIN
SELECT e.Name, d.DepartmentName
FROM Employees e
INNER JOIN Departments d ON e.DeptID = d.ID;