22 ms·
there is something "missing". The SQL spec specifies `null = null` to be "unknown", where i sometimes expect "true". For MSSQL this can be configured using `SET
by salzig 7y ago
there is something "missing". The SQL spec specifies `null = null` to be "unknown", where i sometimes expect "true". For MSSQL this can be configured using `SET ANSI_NULLS { ON | OFF }`. AFAIK MySQL can't be configured. Don't know about Postgres.
- hobs 7y agoFor what its worth, don't do this - pretty much all db code and practitioners expect three valued logic, not two.
- quietbritishjim 7y agoFor postgres you can just use the separate operator IS NOT DISTINCT FROM to explicitly request this behaviour. In SQLite I think it's just IS. I assume most SQL databases have something similar, and that's a far better solution than applying a global config.
- himinlomax 7y agoThe standard makes sense if you go back to the theoretical basis of SQL. It seems somewhat counter-intuitive only when you think of NULL as a value you set in a cell. When it's the result of a relational operation (such as a LEFT JOIN) however, the default makes sense while considering NULLs as equal to each other is typically not useful.