Null-Safe Comparison With IS DISTINCT FROM

Compare two nullable columns without nulls silently dropping rows from a WHERE clause, using IS DISTINCT FROM instead of not-equal.

SqlData Integrity

Code

snippet
SELECT
    id,
    legacy_email,
    current_email
FROM user_migrations
WHERE legacy_email IS DISTINCT FROM current_email
  AND resolved_at IS NULL
ORDER BY id;

-- Using legacy_email <> current_email instead would silently exclude every
-- row where either side is NULL, which is exactly the mismatch we want.