A composite-key JOIN uses two or more columns together to establish the relationship between records.
Using only one part of a composite key can produce false matches and incorrect reporting.
Match branch accounts using both BranchID and AccountNumber.
SELECT
a.BranchID,
a.AccountNumber,
b.Balance
FROM Accounts a
INNER JOIN AccountBalances b
ON a.BranchID = b.BranchID
AND a.AccountNumber = b.AccountNumber;
Common in banking, inventory, regional systems, contracts, and legacy enterprise databases.
- Multiple columns can form one logical key.
- All key columns should normally be included.
- Missing one key column can create duplicate matches.
- Composite relationships should be documented.
- Indexes may need to support the combined key.
What is a composite key JOIN?
It is a JOIN that uses multiple columns together to uniquely identify matching records.
What happens if one part of the composite key is omitted?
The query may match unrelated rows and produce duplicates or incorrect results.