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

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

PHPz
PHPzforward
2023-08-23 19:37:02967browse

If I supply NULL to MySQLs ASCII() function, what does it return?

In this case, the output of the ASCII() function depends on whether we provide NULL as a string or just NULL. The 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.

The above is the detailed content of If I supply NULL to MySQL's ASCII() function, what does it return?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete