Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: SQL
sqljoinscorrectnessdata-integrity
Exclude empty-string and null sentinel keys when joining
When a join key column allows '' or NULL as 'unknown', exclude those values in the ON clause so unknown rows don't all match each other and corrupt results.
PR: hegnar-shareholders-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codesql
| 1 | LEFT JOIN BELLSHEEP b ON b.new_id = tc.new_id |
Explanation (EN)
Objašnjenje (HR)
Good example
New codesql
| 1 | LEFT JOIN BELLSHEEP b ON b.new_id <> '' AND b.new_id = tc.new_id |
Explanation (EN)
Objašnjenje (HR)