AND requires every specified JOIN condition to evaluate as TRUE before two rows are considered a match.
Multiple conditions can prevent false matches when one column alone is not sufficient.
Match records using both CustomerID and BranchID.
SELECT
c.CustomerName,
a.AccountNumber
FROM Customers c
INNER JOIN Accounts a
ON c.CustomerID = a.CustomerID
AND c.BranchID = a.BranchID;
Used in composite keys, regional systems, financial records, and multi-dimensional relationships.
- AND requires all conditions to match.
- It is common with composite keys.
- It can improve match accuracy.
- Every condition should represent a valid business relationship.
- Missing a condition can create false matches.
Why use AND in a JOIN?
It ensures that multiple required conditions are satisfied before rows are matched.
What happens if one AND condition is false?
The two rows do not qualify as a match.