Home >Database >Mysql Tutorial >If I supply NULL to MySQL's CHAR_LENGTH() function, what does it return?
In this case, the output of CHAR_LENGTH() function depends on the condition that whether we are providing NULL as a string or we are providing simply NULL to it. Following example will demonstrate the difference −
mysql> Select CHAR_LENGTH(NULL); +-------------------+ | CHAR_LENGTH(NULL) | +-------------------+ | NULL | +-------------------+ 1 row in set (0.00 sec) mysql> Select CHAR_LENGTH('NULL'); +---------------------+ | CHAR_LENGTH('NULL') | +---------------------+ | 4 | +---------------------+ 1 row in set (0.00 sec)
It can be observed from the above result set that when we provide NULL as string, CHAR_LENGTH() function will return the number of characters i.e. 4 characters otherwise when we provide only NULL , it will return NULL as output.
The above is the detailed content of If I supply NULL to MySQL's CHAR_LENGTH() function, what does it return?. For more information, please follow other related articles on the PHP Chinese website!