M
maiaeutic
I am querying the production database against a spreadsheet of updates and
looking for mismatches on one column. The format of the query is as follows:
SELECT recat.IOEXSO, recat.IOINSO, recat.IOEXOF, CRMOFFCP1.IOEXSO,
CRMOFFCP1.IOINSO, recat.IOSUBC, CRMOFFCP1.IOSUBC
FROM recat INNER JOIN CRMOFFCP1 ON (recat.IOEXSO = CRMOFFCP1.IOEXSO) AND
(recat.IOINSO = CRMOFFCP1.IOINSO) AND (recat.IOEXOF = CRMOFFCP1.IOEXOF) AND
(recat.IOEXCO = CRMOFFCP1.IOEXCO)
WHERE (((recat.IOSUBC)<>[CRMOFFCP1].[IOSUBC]));
Now when I run this query I get 8 results which correspond to entries in
which the recat.IOSUBC field is NULL and the CRMOFFCP1.IOSUBC file has a
value.
I have found two things ususual about this, however:
1. First of all, it is my understanding that a NULL value in a field will
not produce a meaningful comparison to a non-NULL field; i.e. I don’t
understand why these results are being returned in the first place since for
every row returned the value of IOSUBC in recat is NULL.
2. Secondly, I can’t seem to reproduce this result by generating my own
table in which I populate the recat.IOSUBC field with NULL values, and then
duplicate all the other values in both tables. When I run this query using a
manually generated “dummy†table I don’t get any results, which again
indicates to me that NULL fields do not compare to non-NULL fields.
3. When I run the same query and switch to option “2†for the join fields
between the two tables, I get no results. This is also counterintuitive, as
I don’t understand how you could ever get fewer records on an outer left join
than the same query run as an inner join.
looking for mismatches on one column. The format of the query is as follows:
SELECT recat.IOEXSO, recat.IOINSO, recat.IOEXOF, CRMOFFCP1.IOEXSO,
CRMOFFCP1.IOINSO, recat.IOSUBC, CRMOFFCP1.IOSUBC
FROM recat INNER JOIN CRMOFFCP1 ON (recat.IOEXSO = CRMOFFCP1.IOEXSO) AND
(recat.IOINSO = CRMOFFCP1.IOINSO) AND (recat.IOEXOF = CRMOFFCP1.IOEXOF) AND
(recat.IOEXCO = CRMOFFCP1.IOEXCO)
WHERE (((recat.IOSUBC)<>[CRMOFFCP1].[IOSUBC]));
Now when I run this query I get 8 results which correspond to entries in
which the recat.IOSUBC field is NULL and the CRMOFFCP1.IOSUBC file has a
value.
I have found two things ususual about this, however:
1. First of all, it is my understanding that a NULL value in a field will
not produce a meaningful comparison to a non-NULL field; i.e. I don’t
understand why these results are being returned in the first place since for
every row returned the value of IOSUBC in recat is NULL.
2. Secondly, I can’t seem to reproduce this result by generating my own
table in which I populate the recat.IOSUBC field with NULL values, and then
duplicate all the other values in both tables. When I run this query using a
manually generated “dummy†table I don’t get any results, which again
indicates to me that NULL fields do not compare to non-NULL fields.
3. When I run the same query and switch to option “2†for the join fields
between the two tables, I get no results. This is also counterintuitive, as
I don’t understand how you could ever get fewer records on an outer left join
than the same query run as an inner join.