MySQL NOT operator
NOT operator
MySQL NOT operator reverses or negates the input.
Syntax:
NOT, !
The operator returns 1 if the operand is 0 and returns 0 if the operand is nonzero. It returns NULL if the operand is NOT NULL.
MySQL Version: 5.6
Example: MySQL NOT operator
In the following MySQL statement, NOT operator negates the input 10, it returns 0.
Code:
SELECT ! 10;
Output:
Example of MySQL NOT operator with zero input
In the following MySQL statement, NOT operator negates the input 0, it returns 1.
SELECT ! 0;
Sample Output:
MySQL> SELECT ! 10; +------+ | ! 10 | +------+ | 0 | +------+ 1 row in set (0.00 sec)
Example of MySQL NOT operator with zero input
In the following MySQL statement, NOT operator negates the input 0, it returns 1.
Sample Output:
MySQL> SELECT ! 0; +-----+ | ! 0 | +-----+ | 1 | +-----+ 1 row in set (0.00 sec)
Example of MySQL NOT operator with NULL
In the following MySQL statement, NOT operator negates the input NULL, it returns NULL.
SELECT ! NULL;
Sample Output:
MySQL> SELECT ! NULL; +--------+ | ! NULL | +--------+ | NULL | +--------+ 1 row in set (0.00 sec)
Example of MySQL NOT operator with non-zero input
In the following MySQL statement, NOT operator negates the input (10+10), it returns 0.
SELECT ! (10+10);
Sample Output:
MySQL> SELECT ! (10+10); +-----------+ | ! (10+10) | +-----------+ | 0 | +-----------+ 1 row in set (0.00 sec)
Previous: AND operator
Next: OR operator
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework