Answer the question
In order to leave comments, you need to log in
A few questions about NULL?
1) NULL when compared with any type returns NULL?
2) NULL is evaluated as false?
3) Why can't you directly compare with NULL (myfield = NULL), but use IS NULL / IS NOT NULL? Why such logic?
Answer the question
In order to leave comments, you need to log in
1) When using operators =, <, >, <>
- yes
2) No. But at the same time it is not true, i.e. when used in WHERE or JOIN, the condition with it will work as false. Well, outside the database, for example, in PHP and other weakly typed languages, it easily turns into false
3) Some kind of strange question, inverted. The IS NULL / IS NOT NULL operators were invented because the comparison with NULL ordinary operators does not work the way everyone is used to. In general, in SQL ternary logic (for example =):
= | TRUE FALSE NULL
________________________________
TRUE | TRUE FALSE NULL
FALSE | FALSE TRUE NULL
NULL | NULL NULL NULL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question