Explain the difference between an INNER JOIN and a LEFT JOIN. When would you use a CROSS JOIN or a SELF JOIN in a real-world application?

Last updated 3 July 2026

An INNER JOIN returns only matching rows from both tables, while a LEFT JOIN returns all rows from the left table plus matches (NULL where none exist). CROSS JOIN and SELF JOIN serve more specialized needs.

  • INNER JOIN vs LEFT JOIN:

    • INNER JOIN: intersection, unmatched rows dropped.

    • LEFT JOIN: all left rows kept; use it to preserve records that may have no related data (e.g., customers with no orders).

  • CROSS JOIN in practice: Generating all combinations, such as pairing every product with every available color/size, or building a calendar grid.

  • SELF JOIN in practice: Relating rows within one table, like matching each employee to their manager in the same employees table, or finding duplicate/related records.

[lang:sql] -- Customers and their orders, keeping customers with none SELECT c.name, o.id FROM customers c LEFT JOIN orders o ON o.customer_id = c.id;

  • https://medium.com/@harsh1995hg/the-join-jigsaw-mastering-sql-joins-for-real-world-data-analysis-e001ea442930
  • https://dev.to/mohammad1105/sql-joins-explained-connecting-data-across-tables-1l0h
  • https://www.freecodecamp.org/news/understanding-sql-joins/
  • https://dev.to/luca1iu/mastering-sql-joins-inner-outer-cross-and-self-joins-with-examples-2fi1
  • https://bizarro.dev.to/t/oracle/page/29
  • https://dev.to/luca1iu/sql-performance-tuning-best-practices-for-faster-queries-28im
  • https://medium.com/@waheedarshad239/important-interview-questions-for-sql-2026-c39307a7a012
  • https://dev.to/patrickomondi/-sql-joins-how-to-combine-tables-the-right-way-1176
All SQL interview questions