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.
Learn about SQL three-valued logic before it bites you
11–18 of 18 posts
Re: Learn about SQL three-valued logic before it bites you
#12I 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.
SELECT * FROM Foobar WHERE Val = NULL;
no resultsI'm admittedly still learning SQL, but I'm very surprised by this.
The query should be:
SELECT * FROM Foobar WHERE Val IS NULL;Re: Learn about SQL three-valued logic before it bites you
#13Earlier quoted context omitted.
While I’m sure NULLs nary be found in the ivory tower, you should know they are pervasive in the rest of the kingdom amongst us common folk.
The comment you're replying to acknowledges this and suggests we plan accordingly.
How does it suggest we actually go about modeling missing values in the database?
I can think of a dozen ways to go about it and each one has its own tradeoffs and consequences.
When it comes down to it, is actually it worth it? Just so you don’t have to consider NULL scenarios for columns that are marked as nullable?
It seems like a silly overcorrection to me.
Re: Learn about SQL three-valued logic before it bites you
#14The crazy thing is that this person was using DBs for 15 years. Have they only ever used != with non-null columns before? Hard to imagine.
Re: Learn about SQL three-valued logic before it bites you
#15I 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.
If no one would expect NULL != 'crazy' to be True.
That's just intuitive, Null is not the string 'crazy'.
Re: Learn about SQL three-valued logic before it bites you
#16I 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.
Re: Learn about SQL three-valued logic before it bites you
#17The definition and use of markers for missing values belongs in the application, not the database. My 0,02€.
Re: Learn about SQL three-valued logic before it bites you
#18I 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.
Which is why these comparisons should be errors, rather than producing gibberish results. Trinary logic stuffed into Boolean operations is just psychotic