I am just curious - I know about NULL safe equal operator <=>
, but is there some NULL safe NOT equal operator? Or I have to always use something like this:
(tab.id != 1 OR tab.id IS NULL)
or someone prefers
!(tab.id <=> 1)
NULL -safe equal. This operator performs an equality comparison like the = operator, but returns 1 rather than NULL if both operands are NULL , and 0 rather than NULL if one operand is NULL . The <=> operator is equivalent to the standard SQL IS NOT DISTINCT FROM operator.
MySQL null safe equal to operator performs an equality comparison like the equal to (=) operator, but returns 1 rather than NULL if both operands are NULL, and 0 rather than NULL if one operand is NULL.
not equal to (<>, !=) operator. MySQL Not equal is used to return a set of rows (from a table) after making sure that two expressions placed on either side of the NOT EQUAL TO (<>) operator are not equal.
I found that NOT (NULL <=> 1)
works and I think it is also ISO standard compliant, but is cumbersome. A better way to show using column names would be like this: NOT (tbl.col1 <=> 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With