
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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.
- Related Articles
- What MySQL ASCII() function returns if I will provide NULL to it?
- What MySQL CHAR_LENGTH() function returns if no parameter is provided to it?
- What happens if we provide NULL as an argument to MySQL CHAR() function?
- What MySQL returns if I provide a non-hexadecimal number as an argument to UNHEX() function?
- What MySQL COALESCE() function returns if all the arguments provided to it are NULL?
- What is the purpose of using MySQL CHAR_LENGTH() function? Which function is the synonym of it?
- What is the difference between MySQL LENGTH() and CHAR_LENGTH() function?
- What MySQL returns if we provide value larger than 255 as argument to MySQL CHAR() function?
- How can I return 0 for NULL in MySQL?
- Sum if all rows are not null else return null in MySQL?
- What MySQL returns if the argument of QUOTE() function is NULL?
- What happens if I will use integer values as arguments of MySQL LOCATE() function?
- What MySQL COALESCE() function returns if it has a blank, but not NULL, as the first argument?
- What MySQL returns if the first argument of INTERVAL() function is NULL?
- What MySQL EXPORT_SET() function returns if any of the argument is NULL?

Advertisements