Home > Database > Mysql Tutorial > If I supply NULL to MySQL's CHAR_LENGTH() function, what does it return?

If I supply NULL to MySQL's CHAR_LENGTH() function, what does it return?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-08-23 16:54:48
forward
1098 people have browsed it

If I supply NULL to MySQLs 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)
Copy after login

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template