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)
从上面的结果集中可以观察到,当我们将NULL作为字符串提供时,CHAR_LENGTH()函数将返回字符的数量,即4个字符,否则当我们仅提供NULL时,它将返回NULL作为输出。
以上是如果我将NULL提供给MySQL的CHAR_LENGTH()函数,它会返回什么?的详细内容。更多信息请关注PHP中文网其他相关文章!