NULL
is a value like infinity is a number. In other words, not at all. NULL
is the absence of certain information.
Hence, for the same reason that NaN
(not a number) in IEEE754 floating point is not equal to other instances of NaN
(or even the same instance), nothing in SQL is equal to NULL
, including NULL
.
That's something that may sound strange but, when you think of the purpose of NULL
, that of specifying unknown or inappropriate values, it makes sense. If you don't know what A
is and you don't know what B
is, you can't really say for certain that they're equal.
Therefore, with comparisons with NULL
, MySQL will give you back NULL
(unknown), as per the following transcript:
> select 1 = 1 as A, 1 = NULL as B, NULL = NULL as C, NULL is NULL as D;
A B C D
1 NULL NULL 1
In order to see if a value is NULL
, you have to use is
rather then =
, as per the "D" case above. For your case, that would be something like:
SELECT * FROM `datatablecoulmn` WHERE `FkID` is NULL
More details on working with NULL
in MySQL can be found here.
And, though this isn't actually relevant to your question, you may want to think about the spelling of your table name (assuming it's not just a typo made when posting the question). Specifically "column" rather than "coulmn".