3 ms·
> Simply, 1 + NULL = NULL, and we expanded that to all expressions. That's not quite right. In SQL NULL represents an unknown value, so 1 + unknown => unknown.
by karmakaze 5y ago
> Simply, 1 + NULL = NULL, and we expanded that to all expressions.
That's not quite right. In SQL NULL represents an unknown value, so 1 + unknown => unknown.
TRUE OR NULL => TRUE
FALSE OR NULL => NULL
FALSE AND NULL => FALSE
TRUE AND NULL => NULL
Which is also why NULL = NULL => NULL, i.e. unknown == unknown => unknown.
- deleted 5y ago[deleted]
- grumpyprole 5y agoNULLs in SQL are a mess so I don't think one should try to attach any general meaning to them. Nor should SQL's NULL handling be a model for any other language. For example, 1+NULL is NULL, but adding the same two values via SUM(1, NULL), returns 1.