Computer >> Computer tutorials >  >> Programming >> MySQL

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


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.