In one book I see this syntax:
SELECT * FROM inw WHERE id IS DISTINCT FROM 4;
But I get an error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT FROM 4' at line 1
It's an alternative for:
mysql> SELECT * FROM inw WHERE id is null OR id <> 4;
+------+
| id |
+------+
| NULL |
| NULL |
| 3 |
+------+
Is 'IS DISTINCT FROM' a real MySQL operator?
is distinct from
is defined in the SQL:2003 standard and is a null-safe operator to compare two values.
MySQL supports a "null safe equals" operator: <=>
. If that is negated, you get the same behaviour. (the <=>
corresponds to is not distinct from
)
SELECT *
FROM inw
WHERE not id <=> 4;
SQLFiddle: http://sqlfiddle.com/#!2/0abf2a/3
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