ON is a core SQL keyword that links two datasets or binds an object to an event. In a JOIN, ON introduces the Boolean predicate that determines which rows from each table are combined. In MERGE, it defines the match criteria between the target and source tables. For triggers, ON specifies the table that fires the trigger. In foreign-key definitions, ON precedes cascading actions such as ON DELETE CASCADE or ON UPDATE SET NULL. The ON clause is evaluated after the Cartesian product of the joined tables is formed (except for semi-joins such as LEFT JOIN where filtering rules differ). Because the ON predicate is evaluated before the WHERE clause, it can influence whether unmatched rows survive in outer joins. ON supports any valid Boolean expression, including comparisons, IS NULL checks, subqueries, and complex logical operators. Although ON is widely supported, specific extensions (e.g., INSERT ... ON CONFLICT in PostgreSQL, INSERT ... ON DUPLICATE KEY UPDATE in MySQL) are dialect-specific and not part of the ANSI definition.
search_condition
(Boolean) - Expression evaluated for each row combinationobject_name
(Identifier) - Table or view to which a trigger is attachedcascade_action
(Keyword) - Action executed on DELETE or UPDATE in a foreign key (CASCADE, SET NULL, etc.)JOIN, USING, MERGE, TRIGGER, FOREIGN KEY, ON DELETE, ON UPDATE, WHERE clause
SQL-92 (explicit JOIN...ON syntax)
Use ON for row-matching logic between tables. Use WHERE for post-join filtering. For outer joins, misplacing conditions in WHERE can eliminate the null-padded rows you expect.
Yes for explicit JOIN syntax (INNER, LEFT, RIGHT, FULL). CROSS JOINs or the old comma join can omit it, but they are harder to read and often discouraged.
Logically yes. The database evaluates the join predicate (ON) while forming the joined row set, then applies the WHERE filter. This order is crucial for understanding outer-join results.
Absolutely. ON also names the table that fires a trigger and precedes cascading actions in foreign-key constraints, such as ON DELETE CASCADE.