Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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.


NULLs 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: