Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
What MySQL ASCII() function returns if I will provide NULL to it?
In this case, the output of ASCII() 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 ASCII(null);
+-------------+
| ASCII(null) |
+-------------+
| NULL |
+-------------+
1 row in set (0.00 sec)
mysql> SELECT ASCII('null');
+---------------+
| ASCII('null') |
+---------------+
| 110 |
+---------------+
1 row in set (0.00 sec)
mysql> Select ASCII(NULL);
+-------------+
| ASCII(NULL) |
+-------------+
| NULL |
+-------------+
1 row in set (0.00 sec)
mysql> Select ASCII('NULL');
+---------------+
| ASCII('NULL') |
+---------------+
| 78 |
+---------------+
1 row in set (0.00 sec)
As we can observe from the above result set that when we will provide NULL or null as a string, ASCII() function will return the number code of the first character i.e. number code of N in case of ‘NULL’ and number code of n in case of ‘null’, otherwise when we provide simply NULL then it returns NULL as output.
Advertisements
