As a PHP developer I was surprised when query like this:
SELECT IF(‘Bonus’ <> NULL, 1, 0)
returned 0
Any arithmetic comparison with NULL does not return true or false, but returns NULL instead
As an alternative guys propose <=> operator called NULL – safe equal to operator.
So my query will look like this:
SELECT IF(!(‘Bonus’ <=> NULL), 1, 0)
This can be tricky to debug, so hopefully it will help someone.
Leave a Reply