Skip to content

NOT,!

Description

Logical NOT,!. Evaluates to true if the operand is 0, to false if the operand is nonzero, and NOT NULL returns NULL.

Syntax

> SELECT not column_name FROM table_name;

Examples

mysql> select not 0;
+-------+
| not 0 |
+-------+
| true  |
+-------+
1 row in set (0.02 sec)
mysql> select not null;
+----------+
| not null |
+----------+
| NULL     |
+----------+
1 row in set (0.00 sec)
mysql> select not 1;
+-------+
| not 1 |
+-------+
| false |
+-------+
1 row in set (0.01 sec)
create table t1 (a boolean,b bool);
insert into t1 values (0,1),(true,false),(true,1),(0,false),(NULL,NULL);

mysql> select not a and not b from t1;
+-----------------+
| not a and not b |
+-----------------+
| false           |
| false           |
| false           |
| true            |
| NULL            |
+-----------------+
5 rows in set (0.00 sec)

Constraints

! is not supported for now.