v.21.11New Features

Queries with JOIN ON Now Support Disjunctions (OR)

Queries with JOIN ON now supports disjunctions (OR). #21320 (Ilya Golshtein).
Support for disjunctions (OR) in JOIN ON conditions was added to ClickHouse queries.

Why it matters

This feature allows users to write more complex join conditions using logical OR, enabling more flexible data relationships and improving query expressiveness.

How to use it

Users can now include OR expressions directly within the ON clause of JOIN statements. For example:

SELECT *
FROM table1
JOIN table2 ON (table1.id = table2.id OR table1.key = table2.key)


This extends the standard join syntax by allowing multiple alternative join conditions.