Colin, you are overthinking it. Read the original SQL again. I'm not interested in your "similar" example, even though what you said about how to do JOINs is perfectly true. READ THE ORIGINAL SYNTAX LITERALLY. That is what I was responding to. Not the general method but the specific syntax as presented in the original question.
An
ON table1.IdNumber = table2.IdNumber clause works when the predicate {
table1.IdNumber = table2.IdNumber} is TRUE for some records. Can we agree on that? The JOIN will not offer records for which the ON clause's predicate is not TRUE. If no combination of records exhibits that equality, the returned recordset is the Empty Set. Do we also agree on that?
In the SQL as originally written in post #1, there was
also a WHERE clause involving one of the two elements of the ON clause
in the same statement. Of necessity, that means the two clauses (ON and WHERE)
must be referencing the same field. That follows from basic syntax rules for SQL.
That WHERE clause would only select records where
table2.IdNumber IS NULL - which, by implied association through the ON clause
also referencing
table2.IdNumber, means the OP was asking for
table1.IdNumber to be null so as to obtain JOINed records where the ID fields would match, i.e. BOTH be NULL.
Problem is, an ON clause doesn't work for NULLs because you can
never get a TRUE out of that predicate's comparison expression. The NULL in ANY expression ALWAYS propagates that NULL "outward" and therefore what you get back from the given comparison is never TRUE under any circumstances. In this case, it is always NULL. And that means you would get back an empty recordset.
The SQL statement was essentially an anti-tautology. A "real" tautology (like
1=1) is ALWAYS true; an anti-tautology (like
0 = null) is NEVER true. The original question was "why doesn't this query work?" I was answering that question. The query selected no records. It would NEVER select records as originally written.
@Sebastapol - I apologize that we have exposed a disagreement in trying to answer your question. This happens when experienced people get together and look at things through the filter of their past
different experiences. You have done nothing wrong in asking the question. You just happened to pick a topic where this kind of difference could pop up. Once the discussion settles down, we might be able to offer more help.
In a way, this post DOES address why your DELETE query didn't do as you thought it should.