Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What will MySQL CHAR_LENGTH() function return if I provide NULL to it?
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)
As we can observe from the above result set that when we will provide NULL as a string, CHAR_LENGTH() function will return the number of characters i.e. 4, otherwise when we provide simply NULL then it returns NULL as output.
Advertisements