MySQL mystery: Null value is not different from non-null string -
Why is this query returning 0 rows? Choose
from t.f1, t.f2 (select tap F1, 'A' from F2 to double) where t.f1 & lt; & Gt; T.f2;
I have an distilled version of a complex query. I want to compare two tables with one related data from one and I want to select the rows in which some fields Different values can be included but one may be missing one row in one of the tables, the upper pair correctly reverts zero values for these rows, but then, the WHERE section is incorrect (or unused Copy of) the filter these lines.
Why in this case - 'empty' is not different for any tap value (like 'A')?
I'm running madness is that it select
from t.f1, t.f2 (select tap F1, 'A' F2 to Dual) T;
1 row (as I expected) but select
from t.f1, t.f2 (choose null f1, 'a' F2 to dual) where t.f1 = t.f2;
returns 0 rows !! So null is not equal to 'A' and is not different for tap 'A'!
Please ... can anyone explain this?
Absolutely. NULL
represents an unknown value, there is no specific value (it is not in C in NULL
, or zero
etc in Ruby) In SQL, if you compare something with an unknown value, the result is also unknown. And you will not receive those rows where WHERE
condition is unknown.
Try this:
SELECT NULL & lt; & Gt; 2;
and you will see the result as NULL
.
Try this:
SELECT * FROM where to tap;
No more lines will be removed, even if the table t
is too large.
If you really need what you said (and I am not advising), you can do something like this:
SELECT T.f1 , T.F2 (SELECT NULL f1, 'a' f2) is T WHERE ((T. F1 faucet or TF2 tap) and (TFF1 is not zero or TF2) or TF1 and LT; Gt; T.f2
Comments
Post a Comment