MySQL Tutorial/Logic Operator/NOT — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 13:44, 26 мая 2010
NOT: !
Logical NOT.
Return 1 if the operand is 0.
Return 0 if the operand is non-zero.
mysql>
mysql> SELECT NOT 10;
+--------+
| NOT 10 |
+--------+
| 0 |
+--------+
1 row in set (0.00 sec)
mysql> SELECT NOT 0;
+-------+
| NOT 0 |
+-------+
| 1 |
+-------+
1 row in set (0.00 sec)
SELECT NOT;
mysql>
mysql> SELECT NOT (1 - 1);
+-------------+
| NOT (1 - 1) |
+-------------+
| 1 |
+-------------+
1 row in set (0.00 sec)
mysql>
Using NOT with integer value
mysql>
mysql> SELECT ! (1+1);
+---------+
| ! (1+1) |
+---------+
| 0 |
+---------+
1 row in set (0.00 sec)
mysql> SELECT ! 1+1;
+-------+
| ! 1+1 |
+-------+
| 1 |
+-------+
1 row in set (0.00 sec)
Using NOT with NULL value
mysql>
mysql>
mysql> SELECT NOT NULL;
+----------+
| NOT NULL |
+----------+
| NULL |
+----------+
1 row in set (0.00 sec)