SELECT * FROM inw WHERE id IS DISTINCT FROM 4;
But I received 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 is another option:
p>
mysql> SELECT * FROM inw WHERE id is null OR id <> 4;
+------+
| id |
+----- -+
| NULL |
| NULL |
| 3 |
+------+
‘IS DISTINCT FROM’ is a real MySQL operators?
MySQL supports the “null safe equals” operator: <=>. If you negate, you will get the same behavior. (< => corresponds to not the same)
< p>
SELECT *
FROM inw
WHERE not id <=> 4;
SQLFiddle: http://sqlfiddle.com/#!2/ 0abf2a/3
In a book, I saw this syntax:
SELECT * FROM inw WHERE id IS DISTINCT FROM 4;
But I received 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 is another option: p>
mysql> SELECT * FROM inw WHERE id is null OR id <> 4;
+------+
| id |
+------+
| NULL |
| NULL |
| 3 |
+------+
‘ Is IS DISTINCT FROM’ a real MySQL operator?
Different from the definition defined in the SQL:2003 standard, it is a null safe operator that compares two values.
MySQL supports the “null safe equals” operator: <=>. If you negate, you will get the same behavior. (< =>corresponds to not the same)
SELECT * < br />FROM inw
WHERE not id <=> 4;
SQLFiddle: http://sqlfiddle.com/#!2/0abf2a/3
< p>