What are the different types of JOINs and how do they handle non-matching rows?
Last updated
The main JOIN types differ in how they treat rows that have no match on the other side: some drop them, some keep them and pad with NULL.
INNER JOIN: Returns only rows with a match on both sides; non-matching rows are discarded.LEFT (OUTER) JOIN: Keeps all left rows; unmatched right columns becomeNULL.RIGHT (OUTER) JOIN: Keeps all right rows; unmatched left columns becomeNULL.FULL (OUTER) JOIN: Keeps all rows from both sides; missing values on either side areNULL.CROSS JOIN: Cartesian product: every left row paired with every right row, no match condition.
- https://prachub.com/resources/sql-joins
- https://www.geeksforgeeks.org/sql/sql-interview-questions/
- https://www.geeksforgeeks.org/sql/difference-between-inner-join-and-outer-join-in-sql/
- https://medium.com/@AlexanderObregon/sql-anti-joins-for-finding-missing-matches-6339efef032f
- https://www.postgresql.org/docs/current/queries-table-expressions.html
- https://learnsql.com/blog/sql-join-unmatched-rows/
- https://dev.to/katerinamykhailyk/understanding-sql-joins-a-beginners-guide-bkn
- https://medium.com/@Rohan_Dutt/10-common-join-problems-in-sql-and-how-to-fix-them-c11ea52b9af6