SQL Joins and Subqueries/Join with additional predicate

Add extra conditions to the join itself.

Section: Join Conditions and Filters

Join with additional predicate

sql
sql
SELECT o.order_id, s.status
FROM orders o
JOIN shipments s
  ON s.order_id = o.order_id
 AND s.status = 'delivered';
Explanation

Predicates in the ON clause affect join matching behavior.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Join Conditions and Filters
Join to an aggregated subquery
Pre-aggregate a table and join the result.
OpenIn sheetsqlsame section
Find missing related rows
Use LEFT JOIN plus NULL filtering to find unmatched rows.
OpenIn sheetsqlsame section
Use a subquery in WHERE
Filter rows based on results from another query.
Filter with EXISTS
Return rows when a related row exists.
Scalar subquery
Return a single value from a nested query.
Filter with NOT EXISTS
Return rows with no related matches.