Alex Rivera | Logout

Why in SQL NULL can't match with NULL?

Asked 2012-10-12T07:06:52.490
15

I'm new to SQL concepts, while studying NULL expression I wonder why NULL can't match with NULL can anyone tell me a real world example to simply this concept?

Edit
Report

3 Answers

17

NULL indicates an absence of a value. The designers of SQL decided that it made sense that, when asked whether A (for which we do not know its value) and B (for which we do not know its value) are equal, the answer must be UNKNOWN - they might be equal, they might not be. We do not have adequate information to decide either way.

You might want to read up on Three valued logic - the possible results of any comparison in SQL are TRUE, FALSE and UNKNOWN (mysql treats UNKNOWN and NULL as synonymous. Not all RDBMSs do)

answered 2012-10-12T07:10:27.193
4

NULL is an unknown value. Therefore it makes little sense to judge NULL == NULL. That's like asking "is this unknown value equal to that unknown value" - no clue..

See why is null not equal to null false for a possibly better explaination

answered 2012-10-12T07:10:35.343
0

You cannot use = for NULL instead you can use IS NULL

http://www.w3schools.com/sql/sql_null_values.asp

answered 2012-10-12T07:11:44.627

Your Answer