What happens if we provide NULL as an argument to MySQL CHAR() function?

MySQLMySQLi Database

MySQL CHAR() function will ignore NULL if it is provided as an argument to it. To understand it, consider the following examples −

mysql> Select CHAR(65,66,67,NULL);
+---------------------+
| CHAR(65,66,67,NULL) |
+---------------------+
| ABC                 |
+---------------------+
1 row in set (0.00 sec)

mysql> Select CHAR(NULL,66,67,NULL);
+-----------------------+
| CHAR(NULL,66,67,NULL) |
+-----------------------+
| BC                    |
+-----------------------+
1 row in set (0.00 sec)

In both the examples above, CHAR() function ignores the NULL and converts the numeric value into character value.

raja
Published on 21-Feb-2018 12:56:56
Advertisements