4 ms·
SQL NULLs propagate; you can't get an answer from a NULL unless you explicitly plan for it.
by wvenable 11y ago
SQL NULLs propagate; you can't get an answer from a NULL unless you explicitly plan for it.
- nitrogen 11y agoIt can be a bit counterintuitive that "([NULL] < x)" and "NOT ([NULL] < x)" both return NULL in SQL. MariaDB [(none)]> select null as a union all select 1 as a; +------+ | a | +------+ | NULL | | 1 | +------+ 2 rows in set (0.01 sec) MariaDB [(none)]> select * from (select null as a union all select 1 as a) T where a >= 1; +------+ | a | +------+ | 1 | +------+ 1 row in set (0.00 sec) MariaDB [(none)]> select * from (select null as a union all select 1 as a) T where NOT a >= 1; Empty set (0.00 sec)
- jeffdavis 11y agoThat's false. SELECT SUM(x) FROM foo; If some x values are NULL and others not, you will never know.