Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 28 Oct 2003 @ 08:56:37 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Is the following correct ?
 
From:   David Wellman

Narayan,

Yes it's correct.

You are asking the dbms to compare two values (in this case both of them are NULL) and give you a row in the result set where they are equal. In the dbms world, NULL represents an "unknown" value, so you are effectively asking;

Is one unknown value equal to another unknown value ?

Logic dictates that the answer to this question can never be accurately known, and so the dbms must assume that the answer is FALSE, hence the row does not end up in the answer set. I'm not certain but I suspect that most dbms's will generate the same answer.

As per the SQL manuals the only way to explicitly search for null is by using IS NULL or IS NOT NULL. If your question is;

Is one value equal to another ? and you want to treat two NULLs as equal

then the sql to use is:
sel A.a,B.a from t2 A, t2 B
where (A.b = B.b OR (A.b is null and B.b is null));


Cheers,

Dave



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023