2 ms·
I don't find this behaviour crazy or unexpected at all. NULL doesn't refer to any specific 'missing value' state, instead it represents a larger group of possi
by eddd-ddde 3y ago
I don't find this behaviour crazy or unexpected at all.
NULL doesn't refer to any specific 'missing value' state, instead it represents a larger group of possible values of which we don't know the actual value.
So in a pile of values 'foo' and 'bar', NULL could mean either of them, so there is no way of knowing if a NULL row is foo or if it is bar. We can't even know if two NULLS are equal.
- patmorgan23 3y agoIs NULL = 'crazy', True? If no one would expect NULL != 'crazy' to be True. That's just intuitive, Null is not the string 'crazy'.
- sattoshi 3y agoThis reads like you have worked with SQL a lot and has a skewed perspective. As a newcomer to SQL, this could be very surprising given that this diverges from every language that Im aware of having nulls.
- itishappy 3y agoSELECT * FROM Foobar WHERE Val = NULL; no results I'm admittedly still learning SQL, but I'm very surprised by this. The query should be: SELECT * FROM Foobar WHERE Val IS NULL;
- setr 3y agoWhich is why these comparisons should be errors, rather than producing gibberish results. Trinary logic stuffed into Boolean operations is just psychotic
- Xcelerate 3y agoYeah, I agree. The focus here should be the principle of least surprise so your database works correctly. Throw an error to ensure that unintuitive edge cases are handled explicitly. This is SQL after all. It’s used for business purposes, not to demonstrate elegant type systems built around relational algebra.