In MySQL, how can we get the number code of a particular character?

MySQLMySQLi Database

With the help of MySQL string function ASCII(), we can get the number code of a particular character. Its syntax is ASCII(str) where, str, the argument of ASCII() function, is the string whose ASCII value of the first character to be retrieved.

It will return the number code the left the most character i.e. first character of the string given as argument.

Example

mysql> Select ASCII('T');
+------------+
| ASCII('T') |
+------------+
|         84 |
+------------+
1 row in set (0.01 sec)

mysql> Select ASCII('t');
+------------+
| ASCII('t') |
+------------+
|        116 |
+------------+
1 row in set (0.00 sec)

mysql> Select ASCII('Tutorialspoint');
+-------------------------+
| ASCII('Tutorialspoint') |
+-------------------------+
|                      84 |
+-------------------------+
1 row in set (0.00 sec)

mysql> Select ASCII('tutorialspoint');
+-------------------------+
| ASCII('tutorialspoint') |
+-------------------------+
|                     116 |
+-------------------------+
1 row in set (0.00 sec)
raja
Published on 20-Feb-2018 11:27:44
Advertisements