Using ! operator in MySQL



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)
Updated on: 2019-12-12T06:45:17+05:30

125 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements