|
|
|
|
|
by jewel
1025 days ago
|
|
> SQL NULL can't be far behind. SQL's NULL is far more useful though, since NULL != NULL. That lets you do things like join two tables with a column and not have the NULLs match. Consider, for example: select * from users where id = null;
That will give 0 results, even if somehow you have a user with a null id.It's also really nice for non-ID, non-reference fields to represent N/A. For example, user.birthdate can be NULL if the birthdate is not known. SQL also lets you choose when you want NULL to be allowed for a column, so it's less likely to be a gotcha. |
|
That's not true! (Nor is it false.) NULL = NULL IS NULL, NULL != NULL IS NULL. I can't overstate this: as soon as either (or both) operand of any binary relational operator is NULL, the whole expression is NULL!
I'm not being an asshole, this is the exact mistake that makes SQL NULL the other billion dollar sink!
This is really funny, because i wasn't aware of laying such a beatiful trap.