NOT
This page is part of MariaDB's Documentation.
The parent of this page is: SQL Operators for MariaDB Xpand
Overview
Logical negation.
USAGE
NOT value
Value Name | Description |
---|---|
| The value to negate |
DETAILS
The NOT
operator evaluates the following value as a truth value and then negates the value.
This means that any value expression that evaluates as logical true (a non-zero number) returns 0
(false) and any value that evaluates as logical false (zero) returns 1
(true).
A string is evaluated as a number, which parses any leading numerical content out of the string. A string with no numerical content is parsed as a zero.
A NULL
is returned if the value expression is NULL
.
The operator expression NOT x
behaves in exactly the same manner as the function call NOT(x)
.
SYNONYMS
The following are synonyms for NOT:
!
EXAMPLES
SELECT NOT 42, NOT 0, NOT NULL;
+--------+-------+----------+
| NOT 42 | NOT 0 | NOT NULL |
+--------+-------+----------+
| 0 | 1 | NULL |
+--------+-------+----------+
CREATE TABLE not_example (
description VARCHAR(20),
example INT
);
INSERT INTO not_example VALUES
('Everything', 42),
('Dalmations', 101),
('Agent', 99),
('B. Doz.', 13),
('CPU', 64);
SELECT *
FROM not_example
WHERE NOT (example = 101 OR description = 'B. Doz.');
+-------------+---------+
| description | example |
+-------------+---------+
| Everything | 42 |
| Agent | 99 |
| CPU | 64 |
+-------------+---------+