I have a SQL View that joins two tables on 4 fields.
Three of the 4 fields, in both tables, are populated. The fourth isnt. They contain NULL values instead.
I only want to return records that DONT exist in both tables.
The problem is that the view doesn't recognise the NULL values as matching, and so the record is returned, when I'd expect it to be excluded.
If I remove this 4th JOIN, the View works and the record is excluded from the results. However this isnt an option.
I'm currently using this code within the WHERE clause (cutdown version):
(KX.Field1 <> FX.Field1) OR
(KX.Field1 IS NULL) AND (FX.Field1 IS NOT NULL) OR
(KX.Field1 IS NOT NULL) AND (FX.Field1 IS NULL)
This seems to work fine if one side is a NULL, but not both.
I didnt think this would be too difficult...!!?
Three of the 4 fields, in both tables, are populated. The fourth isnt. They contain NULL values instead.
I only want to return records that DONT exist in both tables.
The problem is that the view doesn't recognise the NULL values as matching, and so the record is returned, when I'd expect it to be excluded.
If I remove this 4th JOIN, the View works and the record is excluded from the results. However this isnt an option.
I'm currently using this code within the WHERE clause (cutdown version):
(KX.Field1 <> FX.Field1) OR
(KX.Field1 IS NULL) AND (FX.Field1 IS NOT NULL) OR
(KX.Field1 IS NOT NULL) AND (FX.Field1 IS NULL)
This seems to work fine if one side is a NULL, but not both.
I didnt think this would be too difficult...!!?