What is the benefit of MySQL ‘IS NULL’ and ‘IS NOT NULL’?

MySQLMySQLi Database

As we know that while using NULL with a comparison operator, we would not get any meaningful result set. To get the meaningful result from such kind of comparisons, we can use ‘IS NULL’ and ‘IS NOT NULL’.

Example

mysql> Select 10 IS NULL;
+------------+
| 10 IS NULL |
+------------+
| 0          |
+------------+
1 row in set (0.00 sec)

mysql> Select 10 IS NOT NULL;
+----------------+
| 10 IS NOT NULL |
+----------------+
| 1              |
+----------------+
1 row in set (0.00 sec)

The MySQL statements above show the use of ‘IS NULL’ and ‘IS NOT NULL’. We got the result in Boolean values either 0 (for FALSE) or 1(for TRUE) which is certainly a meaningful result.

raja
Published on 22-Feb-2018 11:01:05
Advertisements