Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 null = null is not true ?!

Author  Topic 

fabianus76
Posting Yak Master

191 Posts

Posted - 2009-02-23 : 06:04:58
Hello all !

I have the following query :

SELECT RecPlus.ID, Product.ID
FROM RecPlus
INNER JOIN Product
ON RecPlus.Element_ID = Product.Element_ID
AND RecPlus.MetaCharacteristic_ID = Product.MetaCharacteristic_ID
AND RecPlus.Origin_ID = Product.Origin_ID

I know that this should give me a record, but it doesn't !
In fact what I discovered is that RecPlus.MetaCharacteristic_ID and Product.MetaCharacteristic_ID are both null in this case. When I get this part of the query off (AND RecPlus.MetaCharacteristic_ID = Product.MetaCharacteristic_ID) the result is correct.
Now I wonder why this is so? Isn't it true that null = null? And if it isn't, how to I have to writ it down in order to make that the MetaCharacteristic_ID fields are inclueded in the join, and that if they are both null, they are counted as equal.

Thanks a lot for any feedback !

Best regards,
Fabianus

my favorit hoster is ASPnix : www.aspnix.com !

fabianus76
Posting Yak Master

191 Posts

Posted - 2009-02-23 : 06:08:06
Excuse-me !

I already asked this question - silly me.

And here is the answer : http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=83973

Regards,
Fabianus

my favorit hoster is ASPnix : www.aspnix.com !
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-02-23 : 07:43:22
Also refer
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/12/24/null-on-joined-columns.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -