IS NULL, IS NOT NULL, truthiness among
other assertions on MySQL and PostgreSQL
People like to complain about JavaScript, how
can one thing be equal to the other, i.e. null ==
undefined evaluates to true unless you use
the triple equals ===. Other dynamic typed languages
have its peculiarities, such as Ruby where
0 == true evaluates to true, the reason
for Ruby is that considers 0 as a value and any
value evaluates to true.
How about SQL? The answer is… it depends.
Which database are you using?
Some may be more forgiving, like MySQL doing
casts for you all over the place, or more strict like
PostgreSQL where you can only compare the
truthiness of something of the same type.
[Read more]