Sobes.tech
Junior

What types of JOIN operators do you know?

sobes.tech AI

Answer from AI

Main types of JOIN operators in SQL:

  • INNER JOIN — returns rows with matches in both tables.
  • LEFT JOIN (LEFT OUTER JOIN) — returns all rows from the left table and matching rows from the right; if no match, NULLs are used.
  • RIGHT JOIN (RIGHT OUTER JOIN) — the opposite, all rows from the right table and matching from the left.
  • FULL JOIN (FULL OUTER JOIN) — returns all rows from both tables; where there are no matches, NULLs are used.
  • CROSS JOIN — Cartesian product of two tables; each row from the first table is combined with each row from the second.

Example of INNER JOIN:

SELECT * FROM employees e
INNER JOIN departments d ON e.department_id = d.id;