What is the difference between the join types?
Practice this questionWANT TO UNDERSTAND THE CONCEPT FIRST?Learn What is the difference between the join types?
Definition:
A join combines rows from two table expressions according to a relationship or condition. Inner joins keep matching pairs, while outer joins also keep unmatched rows from specified sides with NULL values for the missing side. The correct join type follows the business requirement about which records must remain visible.
Key points:
-
INNER: matching rows. LEFT/RIGHT: keep all rows from that side.
-
FULL: keep unmatched rows from both sides; CROSS: every possible pair.
-
SELF JOIN: join a table to itself, such as employees to managers.
-
A self join uses aliases to treat the same table as two roles, such as employee and manager.
Interview point:
- Before writing SQL, say whether rows with no match should appear in the answer.
Adapted from 05_SQL_POSTGRESQL.md · “What is the difference between the join types?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.