|
Posted by Ed Murphy on 11/28/24 11:59
mike wrote:
> Ok I finally got it. I still don't know why that didn't work.
Nulls are not considered equal to anything, not even other nulls.
http://en.wikipedia.org/wiki/Null_(SQL)
> But here is what I did instead and it worked.
> On the join I changed it to the following.
>
> On t1.field1=t2.field1 and (case when t1.field2 is null then '' else
> t1.field2 end)=(case when t2.field2 is null then '' else t2.field2 end)
Equivalent and shorter:
on t1.field1 = t2.field1
and coalesce(t1.field2,'') = coalesce(t2.field2,'')
coalesce() is a function that takes one or more argument and returns the
first non-null value among them, or null if they're all null.
Navigation:
[Reply to this message]
|