Using ! operator in MySQL

MySQLMySQLi Database

For same results, do not use ! operator. The NOT keyword is already provided by MySQL. Let us first create a table −

mysql> create table DemoTable1560
   -> (
   -> Value1 int
   -> );
Query OK, 0 rows affected (0.50 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable1560 values(0);
Query OK, 1 row affected (0.16 sec)

Display all records from the table using select statement −

mysql> select * from DemoTable1560;

This will produce the following output −

+--------+
| Value1 |
+--------+
|      0 |
+--------+
1 row in set (0.00 sec)

Here is the query to use NOT keyword −

mysql> select NOT (NOT Value1), NOT NOT Value1, NOT NOT Value1 from DemoTable1560;

This will produce the following output −

+------------------+----------------+----------------+
| NOT (NOT Value1) | NOT NOT Value1 | NOT NOT Value1 |
+------------------+----------------+----------------+
|                0 |              0 |              0 |
+------------------+----------------+----------------+
1 row in set (0.00 sec)
raja
Published on 12-Dec-2019 06:44:47
Advertisements